使用公钥登陆SSL


apple
linux

在本地生成密钥对

ssh-keygen -t rsa

若是不想设置密码,能够直接点击回车.linux

若是你想使用DSA能够用-t DSA替换.服务器

确保远程计算机上用户目录下有.ssh目录

确保你的链接服务器上的你的home目录下有.ssh目录, 若是没有,可使用上面讲到的ssh-keygen命令长成一个带有正确权限的目录.或者设置.ssh的权限app

  chmod 600ssh

将本地的公钥复制到远程电脑上.

先查看你远程电脑上已经安装的公钥, 在~/.ssh/目录下. 以authorized_keys开头, 能够选择一个没用的名字例如authorized_keys10,使用下面的命令将本地的公钥复制到远程计算机中.spa

scp ~/.ssh/id_rsa.pub remote.server.com:.ssh/authorized_keys2

设置使用私钥加入

  ssh-add ~/.ssh/id_rsacode

Now ssh to the remote server

Now you can ssh to the remote server without entering your password.server

Security

Now keep in mind that all someone needs to login to the remote server, is the file on your local machine ~/.ssh/id_rsa, so make sure it is secure.rem

相关文章
相关标签/搜索