Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What is going on with this article?
@tukiyo3

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

More than 5 years have passed since last update.

インストール

インストール
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

8
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
tukiyo3
最近はC#とBusyBoxと農業してます

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
8
Help us understand the problem. What is going on with this article?