環境は次の通り
次の構成の場合の設定方法
- 経由サーバ nobita (nobita@192.168.111.222:19222)
- 目的サーバ dora (dora@172.16.33.44:22)
- プロトコル: SFTP
~/.ssh/config
Host *
# 鍵認証のみ使用する
IdentitiesOnly yes
# ssh-agent を使用する
AddKeysToAgent yes
# パスフレーズを記憶する
UseKeychain yes
Host nobita
HostName 192.168.111.222
Port 19222
User nobita
IdentityFile ~/.ssh/nobita_priv.pem
SSH Tunnel Manager Preferences
Login: nobita
Host: nobita
Port: 19222
Local redirections (Port / Remote Host / Port)
20044 / 172.16.33.44 / 22
ForkLift
Protocol: SFTP
Server: 127.0.0.1
Username: dora
Password: <Public Key Authentication>(~/.ssh/dora_priv.pem)
Port: 20044
上記のように設定したら、ターミナルから ssh-agent に鍵を登録する
ssh-add -K ~/.ssh/dora_priv.pem
-K オプションを付けることにより、パスフレーズをキーチェーンに保存することができる
If your private key is protected with a passphrase, then open Terminal (Applications > Utilities > Terminal) and run this command to add the passphrase to the ssh-agent:
ssh-add -K /path/to/private_key
How to connect to SFTP using a passphrase protected private key on macOS 10.12 or later?