- 投稿日:2020-06-04T23:35:51+09:00
なぜ?ec2インスタンスの踏み台サーバ経由のSSH接続がうまくいかない
TL;DR
接続したいサーバーのホスト名にパブリックIPを指定していた、プライベートIPの間違いでした
気づくのに3時間ほどかかった分、ProxyCommandとかsshの設定に関して理解が深まっていい経験になりました?やりたかったこと
パブリックなサブネットに踏み台用のec2インスタンスを作成して、プライベートなサーバにsshがしたい!
多段sshは初めてなので見様見真似でやってみるProxyCommandなるものを使うらしいので、こちらの記事を参考に.ssh/configを修正
踏み台サーバーを経由してSSH接続する設定を~/.ssh/configに書く
症状
.ssh/configは以下のように設定
Host humidai User ec2-user HostName 踏み台サーバのパブリックIP IdentityFile ~/.ssh/秘密鍵のファイル名.pem Host honnmei User ec2-user HostName 接続したいサーバのパブリックIP IdentityFile ~/.ssh/秘密鍵のファイル名.pem ProxyCommand ssh humidai -W %h:%pssh honnmei とすると
channel 0: open failed: connect failed: Connection timed out stdio forwarding failed kex_exchange_identification: Connection closed by remote host。。。?
こちらを参考にいろいろ試行錯誤
ssh_exchange_identification: Connection closed by remote host エラーが発生した時の対処しかし一通り検証したが解消できず、、、投げたい
原因
途方にくれた末にこちらの記事にたどり着く
【AWS 再入門】VPC 環境に踏み台サーバーを構築して SSH 接続してみようHostnameにはアプリサーバーインスタンスに割り当てられているPrivate IPsを指定すればOKです。
あ。。。
さっそく
.ssh/configのHostName部分を修正ユーザー@usernoMacBook-Pro-5 ~> ssh honnmei __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ [ec2-user@ip-*.*.*.* ~]$どっつかれた〜〜
- 投稿日:2020-06-04T21:45:13+09:00
最速 rails mail devise ウェルカムメール送信機能実装 一番簡単
【ゴール】
deviseユーザ登録時にmailerを使用してmailの送信(ウェルカムメール)
参考:https://web-camp.io/magazine/archives/19143
参考:https://freesworder.net/rails-mail/【メリット】
■UXの向上
■アプリケーション完成度向上【開発環境】
■ Mac OS catalina
■ Ruby on Rails (5.2.4.2)
■ Virtual Box:6.1
■ Vagrant: 2.2.7【実装】
アプリケーションを作成
mac.terminal$ rails new mail $ cd mailgemfile追加
app内.gemfilegem 'devise' #deviseの会員登録時にメールを飛ばします gem 'dotenv-rails' #環境変数に使用します。詳細は後述ターミナルへ戻り諸々作成
mac.terminal$ bundle install #gemfileをインストール $ rials g devise:install #deviseを初期化 $ rails g devise User $ rails g devise:views $ rails g devise:controllers usersDB,migrationfileを編集、下記のコメントアウ外す。
※メールの情報を追いかける為。
db/migrate/xxxxxxxxxx_devise_create_users.rb# Confirmable t.string :confirmation_token t.datetime :confirmed_at t.datetime :confirmation_sent_at t.string :unconfirmed_email # Only if using reconfirmablemodelを編集
※「:confirmable」のアクセスも追加
user.rbclass User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable ←追加 end.envファイルをルートディレクトリに追加し、下記を追記
※一応パスワードがあるので「.env」を導入、先のgemfile導入はこの為
※環境変数に埋め込passwordは事前に申請してください/.envmail = 'あなたのgamilアドレス' password = 'パスワード申請が必要'config/initializers/mail_config.rb作成、編集
※メールの形式を指定
※「user_name」「password」は上記の.envファイルから引っ張ってきていますconfig/initializers/mail_config.rbActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { address: 'smtp.gmail.com', domain: 'gmail.com', port: 587, user_name: ENV['mail'], password: ENV['password'], authentication: 'plain', enable_starttls_auto: true }view/users/mailer/confirmation_instructions.html編集
confirmation_instructions.html##任意に変更、メールの内容になります。 <p>Welcome <%= @email %>!</p> <p>You can confirm your account email through the link below:</p> ##ここまで <!-- <p><%#= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p> --> #コメントアウト,今回不要の為再度ターミナルへ
mac.terminal$ rails db:migrate $ rails s -b 0.0.0.0以上でユーザー登録時にメール送信されているはずです。
action mailer等経由して3時間くらい時間取られましたが
思ったより簡単に実装できました。
- 投稿日:2020-06-04T21:45:13+09:00
最速 rails mail devise ウェルカムメール送信機能実装 action mailer不要 一番簡単
【ゴール】
deviseユーザ登録時にmailerを使用してmailの送信(ウェルカムメール)
参考:https://web-camp.io/magazine/archives/19143
参考:https://freesworder.net/rails-mail/【メリット】
■UXの向上
■アプリケーション完成度向上【開発環境】
■ Mac OS catalina
■ Ruby on Rails (5.2.4.2)
■ Virtual Box:6.1
■ Vagrant: 2.2.7【実装】
アプリケーションを作成
mac.terminal$ rails new mail $ cd mailgemfile追加
app内.gemfilegem 'devise' #deviseの会員登録時にメールを飛ばします gem 'dotenv-rails' #環境変数に使用します。詳細は後述ターミナルへ戻り諸々作成
mac.terminal$ bundle install #gemfileをインストール $ rials g devise:install #deviseを初期化 $ rails g devise User $ rails g devise:views $ rails g devise:controllers usersDB,migrationfileを編集、下記のコメントアウ外す。
※メールの情報を追いかける為。
db/migrate/xxxxxxxxxx_devise_create_users.rb# Confirmable t.string :confirmation_token t.datetime :confirmed_at t.datetime :confirmation_sent_at t.string :unconfirmed_email # Only if using reconfirmablemodelを編集
※「:confirmable」のアクセスも追加
user.rbclass User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable ←追加 end.envファイルをルートディレクトリに追加し、下記を追記
※一応パスワードがあるので「.env」を導入、先のgemfile導入はこの為
※環境変数に埋め込passwordは事前に申請してください/.envmail = 'あなたのgamilアドレス' password = 'パスワード申請が必要'config/initializers/mail_config.rb作成、編集
※メールの形式を指定
※「user_name」「password」は上記の.envファイルから引っ張ってきていますconfig/initializers/mail_config.rbActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { address: 'smtp.gmail.com', domain: 'gmail.com', port: 587, user_name: ENV['mail'], password: ENV['password'], authentication: 'plain', enable_starttls_auto: true }view/users/mailer/confirmation_instructions.html編集
confirmation_instructions.html##任意に変更、メールの内容になります。 <p>Welcome <%= @email %>!</p> <p>You can confirm your account email through the link below:</p> ##ここまで <!-- <p><%#= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p> --> #コメントアウト,今回不要の為再度ターミナルへ
mac.terminal$ rails db:migrate $ rails s -b 0.0.0.0以上でユーザー登録時にメール送信されているはずです。
action mailer等経由して3時間くらい時間取られましたが
思ったより簡単に実装できました。
- 投稿日:2020-06-04T20:52:02+09:00
MacのVisual Studio Codeが日本語化しなくなって、再インストールしても治らない場合の対処
はじめに
MacのVisual Studio Codeが急に英語表示になり、Visual Studio Codeを再インストールしても日本語化できなかったときの対処です。
こちらのVisual Studio Code の Mac からのアンインストール
を試した後、Japanese Language Pack for Visual Studio Code拡張をインストールし、コマンドパレットの>Configure Display Languageからjaを選択し、再起動しても言語が英語のままで困っている人は、この対処が使えると思います。Visual Studio Codeのアンインストール
アプリケーションフォルダのVisual Studio Codeを削除し、上記のVisual Studio Code の Mac からのアンインストール
を行ます。Application SupportからCodeの削除
ターミナルから、Library/Application Supportを開きます。
cd Library/Application\ Support/Application Supportの中の
Code
を削除します。sudo rm -rf CodeVisual Studio Codeの再インストール
Visual Studio Codeをインストールし、日本語拡張を入れ、コマンドパレットから、Display Languageをenからjpに変更します。再起動後、Visual Studio Codeの言語設定が日本語になっていることを確認します。
- 投稿日:2020-06-04T20:23:31+09:00
MacでCUDAが使えなくなることを誰も不満に思ってないの?
https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#title-new-features
家で機械学習やる人は自作してUbuntu使うのかな。
業務で機械学習やる人はGoogleやAmazonに金を積むのかな
研究室では大学のスパコンや研究室のサーバー使うのかな。
50万ぐらい払ってもいいからMacで機械学習したい人っていると思うんだけどなぁ。
- 投稿日:2020-06-04T17:29:29+09:00
MacBook セットアップメモ (Jun 2020)
これはなに
- 基本的には自分の為の記録
- 他の方のセットアップログは結構役に立つ(例外あり)ので公開する
- 現実的な対応順に記載
- もちろん書けないこともある (かといって別の場所に記録するのもまた面倒)
- Apple信者ではありません
$ sw_vers ProductName: Mac OS X ProductVersion: 10.15.5 BuildVersion: 19F101電源ON && ウィザード
- 言語や地域の設定
- Migration Assistant は使わない (そもそも時間かかりすぎて辛い)
- How to move your content to a new Mac - Apple Support
- Update OS
OS起動直後
基本的には既存マシンの設定と同じ設定にする。
iCloudとKeychain様々だが、移行アシスタントがあまりにも使えないのは謎。
この辺りは他の方の最近の投稿などが参考になることもある。
自分の設定を見直す良い機会。
- Configure
- Computre Name
- Touch ID
- iCloud
- ...
優先度高い対応
- Google Chrome
- Install
- Add accounts
- ATOK Passport
- Install
- Setup
- 正直止め時が中々無いだけ
Applications (息抜き、いつ実施してもまぁ問題無い)
@ App Store
導入済みのものの中から適当に、楽で助かる
(ユーティリティ系は高機能なものよりシンプルなものを好んで使う傾向が強い)
- Debookee Tools
- Wi-Fiの情報表示
- https://apps.apple.com/jp/app/id1110355801
- Randomness
- 適当なパスフレーズとか用意する時に使う、お手軽
- https://apps.apple.com/us/app/id673815312
- Color Note
- カラーピッカー
- https://apps.apple.com/jp/app/id1099028591
- 低機能だがお手軽
- Magnet
- ウィンドウのレイアウト
- https://apps.apple.com/jp/app/id441258766
- GIF Brewery
- Animated GIF 作成
- https://apps.apple.com/jp/app/id1081413713
- FileZilla Pro
- *FTP系GUIクライアント(大嫌い)
- https://apps.apple.com/jp/app/id1298486723
- たまに必要になってた
- Termius
- SSH接続管理など
- https://apps.apple.com/jp/app/id1176074088
- 最近出番が少ない
Copied(は今回見送り)
- クリップボード機能拡張
- https://apps.apple.com/jp/app/id1026349850
- Catalina で不具合、修正される気配無し
- iCloud経由でiPhone等とも同期されて良い感じ(だった)
- Microsoft Office系適当に
- RDPも
App store に無いもしくはあるけど直接本家から
- Clipy - Clipboard extension app for macOS
- クリップボードユーティリティ
- https://clipy-app.com/
- Web browsers
- Firefox
- Edge
- Brave
- Slack
- Discord
- etc.
ここから先は見て分かる人向け (ターミナルとか使わない人は無視してOK、むしろ見ないで)
黒い画面
dot-filesは別途管理しているものを 適宜 適用
- Ricty
- iTerm2 - macOS Terminal Replacement
- Homebrew
- https://brew.sh/
- 個人的にはなるべく使わない方針
- Git
- https://git-scm.com/
- (今回はお手軽Homebrewで)
brew install git
- gitflow-avh
- https://github.com/petervanderdoes/gitflow-avh
- たしかVSCodeの拡張機能かなにかで必要だったはず
- GNU Core Utilities
- https://www.gnu.org/software/coreutils/
$ brew install binutils findutils diffutils coreutils moreutils
*env
必要になった時点で追加して行く方向
- anyenv
- phpenvの為だけに
- nodenv: Manage multiple NodeJS versions.
- Ruby
- rbenv
- Python
- pyenv
- Perl
- plenv
- もうenvは必要無さそう
- PHP
- anyenv+phpenvで
- PHP環境用意するの辛すぎ問題
direnv とか
- 極力使いたくない
Dev tools
必要になった時点で追加して行くのが最善だが、そのうち必ず必要になるものは予めインストールしておく。(もうこういう対応方針もそろそろ不要になりそうな2020年?)
- CotEditor
- テキストエディタ
- https://apps.apple.com/jp/app/id1024640650
- 日本後の半角/全角変換など日本語処理に便利
- Atom
- https://atom.io/
- もう無くても良い気がする
- Docker Desktop on Mac
- Oracle VM VirtualBox
- Vagrant by HashiCorp
- Visual Studio Code - Code Editing. Redefined
- https://code.visualstudio.com/
- 同期は Settings Sync 使ってます
- JetBrains Toolbox App: Manage Your Tools with Ease
- https://www.jetbrains.com/toolbox-app/
- 同期はアカウント使ってJB任せ、Android Studioのみ Settings Repository を利用
- GitHub Desktop | Simple collaboration from your desktop
- https://desktop.github.com/
- 自分では使わない(人に伝える用)
- AWS CLI
- GCP系のCLIとか適当に
- ... また始まる環境破壊と修復の戦い
感想
- 今見ると、ネットワーク系のアプリケーションが全然無いな...
- 前のペチペチキーボードは割と好きだったけど、現モデルもまぁまぁ、なにより静か(ペチペチ版はうるさい)
- 本体の高さ+キー自体の高さでキートップの位置が3mm程度は高くなっているので違和感が凄い
- ペチペチ版みたいに薄い時代に戻って欲しい
最後に
速さは正義
- 投稿日:2020-06-04T16:11:22+09:00
mac 初期設定
mac
- スクロールの向き変更
- キー入力の速度変更
- バッテリー表示を%に変更
- spot 無効
chrome
パスワードはアプリから呼び出す
karabiner-Elements
(https://karabiner-elements.pqrs.org/)
https://qiita.com/daichi87gi/items/ded35e9d9a54c8fcb9d6google 日本語入力
- 全部半角に変更
norton
dropbox
evernote
finder
https://ushigyu.net/2015/05/18/mac-finder-configuration/
spark
slack
illustrator
webstorm
公式に日本語化のプラグインができるた
appcleaner
http://freemacsoft.net/appcleaner/
ターミナル
zsh警告消す
https://qiita.com/waka424/items/bc77b6e8bd4f25760e58https://original-game.com/what-to-do-when-default-shell-is-now-zsh-is-displayed-on-mac/
brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew update brew install brew-cask brew tap homebrew/cask-fonts brew cask install font-ricty-diminished brew install git brew install tigalfred
https://webrandum.net/alfred-syncing/
dash
iterm
そのた
- 投稿日:2020-06-04T13:38:54+09:00
nodebrew入れるときにnodeのPATHが遠らない話(マカー向け)
nodeのPATHが通らない
・.bashrcにはPATHをとおす記述を書く
・.bash_profileには毎回起動時にbashrcを読み込む記述を書く
上記二点は済なのに
.bashrcをコマンド叩いて毎回読み込ませないといけない地獄から抜け出せなかったので何かと思ったら
bashではなくzshを使っていたらしい。。http://pixelbeat.jp/bash_profile_not_working/ を参考に
~/.zprofile に ~/.bash_profile と同じ内容を追記したら直りました。ありがとうございました!
- 投稿日:2020-06-04T10:32:23+09:00
iOSのダウングレード手順
iOSのダウングレード手順を説明します。
iTunes
がなくなったので、Finder
から行います。iOS FW(ips)を以下からダウンロードします。ダウングレードできるバージョンは、
Signed IPSWs
のみ有効です。次に、
Finder
を開いて、ダウングレードしたいデバイスを選択します。次に、macの場合は、
option(alt)
を押しながら、winの場合はshift
を押しながらアップデートを確認
ボタンをクリックします。すると、ファイルを選択できるようになるので、先ほどダウンロードした
.ips
を選択して、ダウングレードできます。