ssh root@127.0.0.1 需要登陆密码
ssh-keygen 生成公钥和私钥 可以去.ssh 查看是否有两个文件 id_rsa id_rsa.pub
ssh-copy-id root(注释:访问者的密码)@127.0.0.1 复制公钥到远程服务器 可以去.ssh 查看是否有 authorized_keys
ssh root@127.0.0.1 不需要登陆密码了
例:
[root@localhost ~]# ls -a
. .bash_logout .config Documents initial-setup-ks.cfg Pictures Templates
.. .bash_profile .cshrc Downloads .local Public Videos
anaconda-ks.cfg .bashrc .dbus .esd_auth Music .ssh .Xauthority
.bash_history .cache Desktop .ICEauthority original-ks.cfg .tcshrc
[root@localhost ~]# cd .ssh
[root@localhost .ssh]# ls
id_rsa id_rsa.pub
[root@localhost .ssh]# ssh-copy-id root@127.0.0.1
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/u