做法如下: (紅色部份請依你的環境修改)
以 ssh-keygen 產生公鑰/私鑰對(public-key & private-key),-t 後面可以是 rsa 或 dsa
$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): idd_dsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in idd_dsa.
Your public key has been saved in idd_dsa.pub.
The key fingerprint is:
92:da:70:c9:7e:fe:05:a4:f9:08:c1:1f:cb:24:f0:f0 root@rich-debian
$ scp idd_dsa.pub richman@remote-server-ip:idd_dsa.pub
登入遠端主機,將公鑰加入遠端帳號下~/.ssh/authorized_keys
$ cat idd_dsa.pub >> .ssh/authorized_keys
接下來就可以直接登入遠端主機不用密碼驗證囉!
$ ssh richman@remote-server-ip
2012/3/28 update!
Recommand use:
$ ssh-keygen -t rsa -b 2048
沒有留言:
張貼留言