一、問題排查
最近在開發中連接配接SSH報錯
使用finalshell報錯:
Session.connect: java.io.IOException: End of IO Stream Read
使用SecureCRT報錯:
Connection reset by 172.20.28.31 port 22
使用telnet檢視22端口正常
telnet 172.20.28.31 22
SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.10
由于使用的是虛機,登入虛機背景控制台檢視ssh運作情況
netstat -tunlp|grep 22
傳回正常:
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5CMihTN5QTOjFTMxMTOihjYhRjZ0IWYwcTYygTZ4YTN18CX5d2bs92Yl1iclB3bsVmdlR2LcNWaw9CXt92Yu4GZjlGbh5yYjV3Lc9CX6MHc0RHaiojIsJye.png)
在網上查找半天,終于在[[mcj]FinalShell無法連接配接ssh:Session.connect: java.io.IOException: End of IO Stream Read-馬春傑傑 (machunjie.com)](
https://www.machunjie.com/linux/122.html)找到了解決方案。
使用 sshd -t 程序測試:
注:測試模式。僅檢查配置檔案的有效性和密鑰的合理性。這适用于在配置選項可能發生更改時可靠地更新 sshd。
it is required that your private key files are not accessible by others
this private key will be ignored
其他人不能通路私鑰檔案
此私鑰将被忽略
需要修改這些私鑰的權限
二、問題解決
使用下面的指令:修改對應權限
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_dsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
重新開機ssh生效,即可連接配接。
三、參考資料
[[mcj]FinalShell無法連接配接ssh:Session.connect: java.io.IOException: End of IO Stream Read-馬春傑傑 (machunjie.com) ](