11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

keychainでsshのprivate鍵パスワード入力回数を減らそう

Last updated at Posted at 2015-04-05

インストール

インストール
apt install keychain

起動

keychain ~/.ssh/id_rsa
複数鍵がある場合は追記
keychain ~/.ssh/id_rsa ~/.ssh/work_id_rsa

利用方法

source ~/.keychain/srv1-sh
接続してみる
ssh myhome

鍵のパスワード入力が省略されていることを確認。

keychainを使わない場合

ssh-agent bash
ssh-add
ssh-add ~/.ssh/work_id_rsa

ssh myhome

zshの場合

参考: CentOSでkeychain - とほほのN88-BASIC日記

~/.zshrcに以下追記

~/.zshrc
/usr/bin/keychain \
  $HOME/.ssh/id_rsa \
  $HOME/.ssh/id_rsa_home \
  $HOME/.ssh/id_rsa_work

source $HOME/.keychain/$HOSTNAME-sh

bashの場合

~/.bashrc
 if [ -d "$HOME/bin" ] ; then
     PATH="$HOME/bin:$PATH"
 fi
 export LANG=ja_JP.UTF-8
 export TERM=xterm-256color
+/usr/bin/keychain ~/.ssh/id_rsa ~/.ssh/work/id_rsa
+source $HOME/.keychain/$HOSTNAME-sh

11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?