linux使用公钥免密ssh登录

生成本机密钥

ssh-keygen -t rsa -f ~/.ssh/id_rsa


把本机的公钥(~/.ssh/id_rsa.pub)拷贝到远端主机并追加到~/.ssh/authorized_keys文件中

cat id_rsa.pub >> ~/.ssh/authorized_keys


修改远端主机目录文件权限

chmod 0600 ~/.ssh/authorized_keys

chmod 0700 ~/.ssh


提交评论