我已经通过 ssh 连接到这台计算机(也是 Ubuntu 16)几个月了,今天它无法正常工作。
运行ssh -v [ip]
收益率
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.0.211 [192.168.0.211] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.0.211:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
Connection reset by 192.168.0.211 port 22
运行nmap -v [ip]
产量
Starting Nmap 7.01 ( https://nmap.org ) at 2018-09-06 08:44 MDT
Initiating Ping Scan at 08:44
Scanning 192.168.0.211 [2 ports]
Completed Ping Scan at 08:44, 0.09s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 08:44
Completed Parallel DNS resolution of 1 host. at 08:44, 0.03s elapsed
Initiating Connect Scan at 08:44
Scanning 192.168.0.211 [1000 ports]
Discovered open port 22/tcp on 192.168.0.211
Discovered open port 80/tcp on 192.168.0.211
Completed Connect Scan at 08:44, 0.49s elapsed (1000 total ports)
Nmap scan report for 192.168.0.211
Host is up (0.012s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.63 seconds
我可以从目的地 ssh 到我的计算机。
IP不在里面/etc/hosts.deny
答案1
把它放在这里是为了防止人们在谷歌上搜索这个问题时遇到一些麻烦。我很难找到一个好的解决方案。我不知道有一个与 ssh 相关的日志文件。
查看服务器上的日志文件(/var/log/auth.log
)发现各个密钥的权限/etc/ssh/
都设置为 755,这太开放了。只有用户应该具有查看这些内容的权限。因此,使用chmod 400
所有受影响的键解决了我的问题。