灌溉梦想,记录脚步
« »
2011年2月18日技术合集

ssh-copy-id

参数:/usr/bin/ssh-copy-id [-i [identity_file]] [user@]machine
作用:拷贝公钥到远程主机,实现登录远程主机无须密码

过程:

//生成公钥

1
2
3
4
5
6
7
8
9
kevin@nb:~$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kevin/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/kevin/.ssh/id_rsa.
Your public key has been saved in /home/kevin/.ssh/id_rsa.pub.
The key fingerprint is:
49:af:93:98:df:8a:e5:62:51:5c:86:12:66:6d:f4:33 kevin@nb

//查看公钥

1
2
3
4
5
6
kevin@nb:~$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvbji+85BMUVkdWw7+TW86Hzk67F0DngYzRgn6/v8
kKZBhwFXh1H6oEjdmGoniliEEeIII7drjMHWbG8Ng6g398ypawy8AoT2DexaCQQC7L9BzcpFlCEjyW6
I7v15ZMwBaIsoJwEmDS7lxvG+wN/2Mo2M6SEFcA+WzjO8MiXZHpvU5kit7UP2yvlFbKW4SZNcLj89
saQHQAyNWn9lTiR2HA5xgM5+B43Wb7pEngsdjh+hPDENznuKjrcAclRHIApx36Cn5foZ71V9lp0oY1/+
XEymwSba94id/4bCfdFf3TVBcr71vZMLHobPvxz8gjh38xomTq2kYA66hVVAvUoxKw== kevin@nb

//拷贝公钥

1
2
3
4
5
6
7
8
9
10
11
kevin@nb:~$ ssh-copy-id root@10.0.50.85
The authenticity of host '10.0.50.85 (10.0.50.85)' can't be established.
RSA key fingerprint is d3:9f:63:a5:e8:24:05:4a:57:54:1b:54:cc:0f:31:65.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.50.85' (RSA) to the list of known hosts.
root@10.0.50.85's password: 
Now try logging into the machine, with "ssh 'root@10.0.50.85'", and check in:
 
  .ssh/authorized_keys
 
to make sure we haven't added extra keys that you weren't expecting.

日志信息 »

该日志于2011-02-18 16:33由 kevin 发表在技术合集分类下, 你可以发表评论。除了可以将这个日志以保留源地址及作者的情况下引用到你的网站或博客,还可以通过RSS 2.0订阅这个日志的所有评论。

发表回复