我想使用 ssh 来连接 localhost,但这是不可能的。当我写
远程控制[电子邮件保护]-p 22
它显示
ssh:连接到主机 127.0.0.1 端口 22:连接被拒绝
我想检查 ssh 状态但出现以下错误:
我认为问题可能与依赖关系有关,所以我把
apt-get 安装 -f
但我也有同样的问题
无法启动 OpenBSD 安全外壳服务器。
怎么了?
@编辑
sudo /usr/sbin/sshd -ddd
显示这个:
debug2: load_server_config: filename /etc/ssh/sshd_config
debug2: load_server_config: done config len = 736
debug2: parse_server_config: config /etc/ssh/sshd_config len 736
debug3: /etc/ssh/sshd_config:5 setting Port 22
debug3: /etc/ssh/sshd_config:9 setting Protocol 2
debug3: /etc/ssh/sshd_config:11 setting HostKey /etc/ssh/ssh_host_rsa_key
debug3: /etc/ssh/sshd_config:12 setting HostKey /etc/ssh/ssh_host_dsa_key
debug3: /etc/ssh/sshd_config:13 setting HostKey /etc/ssh/ssh_host_ecdsa_key
debug3: /etc/ssh/sshd_config:14 setting HostKey /etc/ssh/ssh_host_ed25519_key
debug3: /etc/ssh/sshd_config:16 setting UsePrivilegeSeparation yes
debug3: /etc/ssh/sshd_config:19 setting KeyRegenerationInterval 3600
debug3: /etc/ssh/sshd_config:20 setting ServerKeyBits 1024
debug3: /etc/ssh/sshd_config:23 setting SyslogFacility AUTH
debug3: /etc/ssh/sshd_config:24 setting LogLevel INFO
debug3: /etc/ssh/sshd_config:27 setting LoginGraceTime 120
debug3: /etc/ssh/sshd_config:28 setting PermitRootLogin prohibit-password
debug3: /etc/ssh/sshd_config:29 setting StrictModes yes
debug3: /etc/ssh/sshd_config:31 setting RSAAuthentication yes
debug3: /etc/ssh/sshd_config:32 setting PubkeyAuthentication yes
debug3: /etc/ssh/sshd_config:36 setting IgnoreRhosts yes
debug3: /etc/ssh/sshd_config:38 setting RhostsRSAAuthentication no
debug3: /etc/ssh/sshd_config:40 setting HostbasedAuthentication no
debug3: /etc/ssh/sshd_config:45 setting PermitEmptyPasswords no
debug3: /etc/ssh/sshd_config:49 setting ChallengeResponseAuthentication no
debug3: /etc/ssh/sshd_config:64 setting X11Forwarding yes
debug3: /etc/ssh/sshd_config:65 setting X11DisplayOffset 10
debug3: /etc/ssh/sshd_config:66 setting PrintMotd no
debug3: /etc/ssh/sshd_config:67 setting PrintLastLog yes
debug3: /etc/ssh/sshd_config:68 setting TCPKeepAlive yes
debug3: /etc/ssh/sshd_config:75 setting AcceptEnv LANG LC_*
debug3: /etc/ssh/sshd_config:77 setting Subsystem sftp /usr/lib/openssh/sftp-server
debug3: /etc/ssh/sshd_config:88 setting UsePAM yes
debug1: sshd version OpenSSH_7.2, OpenSSL 1.0.2g 1 Mar 2016
debug1: private host key #0: ssh-rsa SHA256:Lsdpgb64ws0fMhktyreuRoq6sD8iFlBdO9LJ7ple8q0
debug1: private host key #1: ssh-dss SHA256:2HpCxTOIMYTen4ZiFLLCPp78+Vj7FsTydWVKQh6ua8k
debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:0EAGTBAznkE2MuCv+EhNbZup091NrQ4u0Cgi3SeEZBY
debug1: private host key #3: ssh-ed25519 SHA256:54l55EUylmXVbaRFtUOijzhEocqmk+N6RihbIer7vRo
Missing privilege separation directory: /var/run/sshd
答案1
最好的解决方案是删除之前安装的 ssh 服务器/客户端
sudo apt-get remove openssh-server openssh-client --purge && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get update
然后安装新的干净纯净的:
sudo apt-get install openssh-server openssh-client