出現github 連接錯誤:
ssh:connect to host github.com port 22:Connection timed out
剛開始以為是網絡問題,github不能連接上,但是使用ssh命令,用端口443測試發現可以連接上github
ssh -T -p 443 git@ssh.github.com
Enter passphrase for key '/root/.ssh/id_rsa':
Hi yinfei1! You've successfully authenticated, but GitHub does not provide shell access.
於是就懷疑端口22不能使用,端口22為ssh默認端口,初步懷疑和github服務器有關,於是將其端口修改為443:
修改方法
切換到 cd ~/.ssh/
進入到~目錄下面的.ssh下面,修改ssh配置,新建config文件
將上述文件添加配置:
Host github.com /*服務器地址為github地址*/
User "XXX@XX.com" /*github上的注冊郵箱為用戶賬號*/
Hostname ssh.github.com /*服務器地址為github地址*/
PreferredAuthentications publickey /*采用公匙*/
IdentityFile ~/.ssh/id_rsa /*公匙文件路徑*/
Port 443 /*修改端口為443*/