现在的位置: 首页我爱Linux>正文
ssh-copy-id使用
发表于7年前 我爱Linux 暂无评论 ⁄ 被围观 3,129 次+

复制SSH密钥到目标主机,开启无密码SSH登录

生成key

[root@host30 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
3a:33:30:5e:63:17:61:35:cb:5b:66:ae:be:f7:98:de root@host30
复制key.pub到目标主机

[root@host30 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub host32
21
root@host32's password:
Now try logging into the machine, with "ssh 'host32'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
登录目标主机,这次登录就不用密码了

[root@host30 ~]# ssh host32
Last login: Wed Jun 29 10:51:30 2011 from 192.168.5.30
 

给我留言

留言无头像?