Ubuntu

sshd 在 lxc (ubuntu) 中不起作用(但已啟動)

  • August 8, 2016

當我嘗試連接時,ssh ubuntu@10.0.0.*它會失敗Read from socket failed: Connection reset by peer,我只能使用lxc-attach -n (name).

我怎樣才能解決這個問題?

更新 0:

$ ssh -vvv ubuntu@10.0.0.243
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.0.0.243 [10.0.0.243] port 22.
debug1: Connection established.
debug1: identity file /home/guava/.ssh/id_rsa type -1
debug1: identity file /home/guava/.ssh/id_rsa-cert type -1
debug1: identity file /home/guava/.ssh/id_dsa type -1
debug1: identity file /home/guava/.ssh/id_dsa-cert type -1
debug1: identity file /home/guava/.ssh/id_ecdsa type -1
debug1: identity file /home/guava/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/guava/.ssh/id_ed25519 type -1
debug1: identity file /home/guava/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "10.0.0.243" from file "/home/guava/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer

您可以嘗試將 verbose svitch 添加到 ssd 命令以進行調試:

ssh -vvv ubuntu@10.0.0.1

-v - 代表verbose,可以多選項,最大cuont是3

UPD0

權限設置正確嗎?

sudo chmod 644 ~/.ssh/known_hosts
sudo chmod 755 ~/.ssh
sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa.pub

在遠端主機上:

sudo chmod 600 /etc/ssh/ssh_host_*

兩台機器上的時間是否同步?

更新 1

你能把尾巴放在遠端機器的 auth.log 上嗎?

tail -500 /var/log/auth.log | grep 'sshd'

/etc/ssh/sshd_configlog_level 調試/資訊中:

SyslogFacility AUTH
LogLevel INFO

引用自:https://serverfault.com/questions/741455