ssh-agentでパスワードを保持させ、~/.ssh/configに「ForwardAgent yes
」と書いておくことで実現できる。
ssh-agentとは
ssh-agentの使い方(Mac OS X環境)
Mac OS Xにおいてはsshするとssh-agentが起動されるので、起動不要。
秘密鍵の登録状況の確認
$ ssh-add -l The agent has no identities.
秘密鍵の登録
~% ssh-add .ssh/id_rsa
Identity added: .ssh/id_rsa (.ssh/id_rsa)
~% ssh-add -l
2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx .ssh/id_rsa (RSA)
接続先における秘密鍵の情報の引き継ぎ方
$ ssh -A ホスト名
.ssh/configの活用
下記のように設定するとhogehostへsshする際に -Aオプションとユーザー名の指定が省略できる。
$ vim ~/.ssh/config ForwardAgent yes Host hogehost User fuga