1. ローカルとリモートの ~/.ssh は消した。

  2. 公開鍵を生成

cygwin % ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/masutaka/.ssh/id_rsa):       # <= Enter(default)
Created directory '/home/masutaka/.ssh'.
Enter passphrase (empty for no passphrase):                             # <= パスワードを入力
Enter same passphrase again:                                            # <= もう一度パスワードを入力
Your identification has been saved in /home/masutaka/.ssh/id_rsa.
Your public key has been saved in /home/masutaka/.ssh/id_rsa.pub.
The key fingerprint is:
e2:21:e7:04:ae:ef:09:46:0c:c4:3c:f0:64:6a:10:3e masutaka@PCCHRONO
  1. 公開鍵ができたことを確認
cygwin % ls -alF ~/.ssh
合計 2
drwx------+   2 masutaka なし            0 Sep 23 01:43 ./
drwx------+  13 masutaka なし            0 Sep 23 01:45 ../
-rw-------    1 masutaka なし          951 Sep 23 01:43 id_rsa
-rw-------    1 masutaka なし          227 Sep 23 01:43 id_rsa.pub
  1. 接続先に ~/.ssh を作成
linux % (cd && mkdir .ssh && chmod go-rwx .ssh)
  1. 接続先に公開鍵を登録
cygwin % cat ~/.ssh/id_rsa.pub | ssh chronicle "cat >> .ssh/authorized_keys2"
The authenticity of host 'chronicle (192.168.0.3)' can't be established.
RSA key fingerprint is 0c:9d:af:25:c3:84:40:63:b8:80:d0:f8:b3:22:b9:49.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'chronicle,192.168.0.3' (RSA) to the list of known hosts.
masutaka@chronicle's password:                                          # <= パスワードを入力
id_rsa.pub                    100%  227     5.1KB/s   00:00
  1. パスワードを記憶させるために ssh-agent と呼ばれるデーモンを利用する。
cygwin % eval `ssh-agent`
Agent pid 3164
  1. パスワードを記憶させる。
cygwin % ssh-add
Enter passphrase for /home/masutaka/.ssh/id_rsa:                        # <= パスワードを入力
Identity added: /home/masutaka/.ssh/id_rsa (/home/masutaka/.ssh/id_rsa)
  1. ssh-agent を終了する。
cygwin % ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 3164 killed;

URL: http://www.is.math.sci.ehime-u.ac.jp/~vava/memo/ssh_rsa.html