ssh: connect to host **.**.**.**
port 22: No route to host
服務(wù)器不存在道媚,可能沒(méi)開機(jī)或者不在同一個(gè)網(wǎng)絡(luò)中膝但。
ssh: connect to host **.**.**.**
port 22: Connection refused
ssh 服務(wù)的端口可能改了,默認(rèn)是 22,很多時(shí)候出于安全考慮會(huì)調(diào)整端口。此外也有可能是 ssh 服務(wù)沒(méi)有開啟溉奕。
密碼正確,但不能連接
類似這種提示(關(guān)于 Permission denied
還有很多原因忍啤,看后面):
Permission denied, please try again.
多半是因?yàn)槟闶褂昧?root 身份登錄加勤,而服務(wù)器沒(méi)有開啟 root 用戶登錄 ssh 的權(quán)限。
解決辦法:
# 修改 /etc/ssh/sshd_config
PermitRootLogin no 改為 PermitRootLogin yes
Host key verification failed.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
顯而易見同波,證書不匹配鳄梅,直接刪掉 ~/.ssh/known_hosts
文件不失為一個(gè)快捷的解決辦法。
Permissions 0755 for '/User/xxxx/.ssh/id_rsa' are too open.
遇到這種情況:
Macintosh:Permissions 0755 for '/User/xxxx/.ssh/id_rsa' are too open.
Linux:Permissions 0755 for '/home/xxxx/.ssh/id_rsa' are too open.
這是說(shuō)你的私鑰權(quán)限太大, 所以需要只有你來(lái)操作
sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa.pub
Failed to add the host to the list of known hosts
遇到下面這種情況說(shuō)明的 known_hosts 文件的權(quán)限有問(wèn)題
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts
執(zhí)行這行命令
sudo chmod 644 ~/.ssh/known_hosts
最后你需要把你的 .ssh 文件夾的權(quán)限設(shè)置正確, 執(zhí)行下面命令
sudo chmod 755 ~/.ssh
如何定位問(wèn)題
上面兩種情況默認(rèn)也會(huì)返回 Permission denied 的提示未檩。所以為了更好定位問(wèn)題戴尸,在使用 ssh 時(shí)可以使用 -v 參數(shù)查看更多信息。這樣會(huì)更容易定位問(wèn)題讹挎。