Garey's Blog–FreeBSD/PHP/GoLang

十二月 15th, 2009

OpenSSH设置RSA密钥登陆

4,485 views, FreeBSD, by garey.

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/garey/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/garey/.ssh/id_rsa.
Your public key has been saved in /home/garey/.ssh/id_rsa.pub.
The key fingerprint is:
57:57:65:2e:29:05:dd:23:37:b1:39:28:8b:93:f5:3a garey@test.bsdart.org
The key’s randomart image is:
+–[ RSA 2048]—-+
| .o.o*|
| ooO+|
| oo.*++|
| +.+o ..|
| S+.. . |
| .. . |
| E |
| . |
| |
+—————–+

cd .ssh/
cp id_rsa.pub authorized_keys

vi /etc/ssh/sshd_config
PasswordAuthentication no
ChallengeResponseAuthentication no
或者
UsePAM no

/etc/rc.d/sshd restart

将私钥id_rsa下载到本地,ssh客户端使用即可。
putty需要用PUTTYGEN.EXE把私钥转换一下才能使用。

Back Top

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*