首先是保存密碼輸入問題,須要建立密鑰,在你的命令行輸入: username$ ssh-keygen -t rsa -C "youremail@example.com" 加上 -C 是用戶建立密鑰郵箱,用在git ssh上 而後依次回車,輸入密碼,這個密碼和SSH的賬號密碼無關. Generating public/private rsa key pair. Enter file in which to save the key (/u/kim/.ssh/id_rsa): 【回車】 Enter passphrase (empty for no passphrase): 【第一次密碼】 Enter same passphrase again: 【第二次密碼】 Your identification has been saved in /u/kim/.ssh/id_rsa. Your public key has been saved in /u/kim/.ssh/id_rsa.pub. 接下來把密鑰文件傳到你的SSH賬號下: local:~ yourname$ cd ~/.ssh local:~ yourname$ cp id_rsa.pub authorized_keys local:~ yourname$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@ip #local:~ yourname$ scp -p ~/.ssh/authorized_keys user@ip:.ssh/ 最後一步會提示你輸入SSH賬號的密碼,不是你剛纔建立密鑰的密碼。 若是最後一步提示錯誤,一般是由於遠程權限的問題。
登陸的時候使用php
username$ ssh user@ip
而後就能夠不用輸入密碼直接登陸到服務器上。git