ssh上传公钥绑定指定用户

在使用ssh上传公钥到目标机器时,如果不指定用户名,则默认是针对于目标机器的root用户,如果需要指定其他用户名,则需要在ip地址之前加上"用户名@",如下例所示:

[root@redhat7 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
 

你可能感兴趣的:(运维)