ssh-keygen -t rsa
若是不想設置密碼,能夠直接點擊回車.linux
若是你想使用DSA能夠用-t DSA替換.服務器
確保你的鏈接服務器上的你的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 you can ssh to the remote server without entering your password.server
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