分类:
2007-03-07 14:39:33
[root@domain ~]$su - tenten查看生成的文件:
[tenten@domain ~]ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tenten/.ssh/id_rsa):[Enter]
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/tenten/.ssh/id_rsa.
Your public key has been saved in /home/tenten/.ssh/id_rsa.pub.
The key fingerprint is:
c7:93:83:c4:24:30:56:90:37:a0:eb:a7:5d:4c:8d:ea:1a: tenten@example.com:::或者:::
[tenten@kdx ~]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/tenten/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/tenten/.ssh/id_dsa.
Your public key has been saved in /home/tenten/.ssh/id_dsa.pub.
The key fingerprint is:
a2:be:16:2e:66:e4:69:68:a0:eb:a7:5d:4c:8d:ea:1a:da:54:35:55:32:8e:e2 tenten@example.com
[tenten@kdx ~]$ ls /home/tenten/.ssh/ -la设置 sshd_config 文件,去除密码认证
total 28
drwx------ 2 tenten tenten 4096 Oct 11 16:09 .
drwx------ 3 tenten tenten 4096 Oct 9 16:50 ..
-rw------- 1 tenten tenten 736 Oct 11 16:09 id_dsa
-rw-r--r-- 1 tenten tenten 612 Oct 11 16:09 id_dsa.pub
-rw------- 1 tenten tenten 951 Oct 11 16:03 id_rsa
-rw-r--r-- 1 tenten tenten 232 Oct 11 16:03 id_rsa.pub
-rw-r--r-- 1 tenten tenten 667 Oct 9 16:48 known_hosts
# To disable tunneled clear text passwords, change to no here!由于在 sshd_config 文件里面,我们设置了以下内容:
PasswordAuthentication no
#AuthorizedKeysFile .ssh/authorized_keys所以我们要把共匙重命名为 autherized_keys
[root@domain .ssh]# mv id_dsa.pub autherized_keys所以最终服务器端 ~/.ssh/ 目录下的内容为(注意authorized_keys的权限为 644)
[tenten@domain .ssh]$ ls -la
total 12
drwx------ 2 tenten tenten 4096 Oct 11 19:57 .
drwx------ 3 tenten tenten 4096 Oct 11 18:50 ..
-rw-r--r-- 1 tenten tenten 232 Oct 11 19:46 authorized_keys
Generating public/private rsa1 key pair.
Your identification has been saved in /usr/local/etc/ssh_host_key.
Your public key has been saved in /usr/local/etc/ssh_host_key.pub.
The key fingerprint is:
22:67:00:5f:82:87:ab:22:e7:8e:cd:bb:d2:07:98:57 root@example.comGenerating public/private dsa key pair.
Your identification has been saved in /usr/local/etc/ssh_host_dsa_key.
Your public key has been saved in /usr/local/etc/ssh_host_dsa_key.pub.
The key fingerprint is:
17:6c:d8:6f:31:db:bd:3c:66:81:86:12:13:a4:33:a3 root@example.comGenerating public/private rsa key pair.
Your identification has been saved in /usr/local/etc/ssh_host_rsa_key.
Your public key has been saved in /usr/local/etc/ssh_host_rsa_key.pub.
The key fingerprint is:
27:0e:16:41:f8:96:ed:93:b6:a8:61:74:fe:87:e2:91 root@example.com
/usr/local/sbin/sshd -t -f /usr/local/etc/sshd_config