1、生成密钥:SSH 密钥默认保留在cd ~/.ssh 目录中含有密钥和公钥,指令如下:
ssh-keygen
2、传输公钥文件到远程机(客户端):如果指定端口号需要配置端口号
ssh-copy-id -p 2223 -o StrictHostKeyChecking=no quicktron@$ip
如果遇到设置免密后无法登录可以尝试如下解决方案,修改服务端~/.ssh权限、删除key密码!
###########################################
#本例子:
#是为了解决配置完成ssh免密登录后
#还是需要添加密码的操作;
###########################################
#删除passphrase密码
root@quicktron-RK:~# ssh-keygen -p
#按回车即可
Enter file in which the key is (/root/.ssh/id_rsa):
#输入老密码
Enter old passphrase:
#回车
Enter new passphrase (empty for no passphrase):
#再次回车
Enter same passphrase again:
Your identification has been saved with the new passphrase.
###########################################
3、登录远程端即可
ssh -p 2223 -o StrictHostKeyChecking=no quicktron@10.255.245.117
登录后exit指令推出指令!