sshd_config已修改,ssh还是无法远程问题解决

环境:vmware下的debian10.2

/etc/sshd/sshd_config 配置文件已经完成修改开启允许root账号登录配置

ssh远程返回如下信息:

[Administrator.NIHAORZ-WORK-PC] ➤ ssh root@192.168.36.135
Connection reset by 192.168.36.135 port 22

通过vmware进入虚拟机查看服务状态返回:

debian:~# systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-12-19 08:57:57 UTC; 14s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 850 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 851 (sshd)
    Tasks: 7 (limit: 9511)
   Memory: 7.6M
   CGroup: /system.slice/ssh.service
           ├─786 sshd: root@pts/0
           ├─788 sshd: root@notty
           ├─790 /usr/lib/openssh/sftp-server
           ├─792 -bash
           ├─851 /usr/sbin/sshd -D
           ├─856 systemctl status sshd
           └─857 pager

Dec 19 08:57:57 debian systemd[1]: ssh.service: Found left-over process 848 (systemctl) in control group while starting unit. Ignoring.
Dec 19 08:57:57 debian systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Dec 19 08:57:57 debian systemd[1]: ssh.service: Found left-over process 849 (systemd-tty-ask) in control group while starting unit. Ignoring.
Dec 19 08:57:57 debian systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Dec 19 08:57:57 debian sshd[851]: Could not load host key: /etc/ssh/ssh_host_rsa_key
Dec 19 08:57:57 debian sshd[851]: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Dec 19 08:57:57 debian sshd[851]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Dec 19 08:57:57 debian sshd[851]: Server listening on 0.0.0.0 port 22.
Dec 19 08:57:57 debian systemd[1]: Started OpenBSD Secure Shell server.
Dec 19 08:57:57 debian sshd[851]: Server listening on :: port 22.

显示缺失ssh_host_rsa_keyssh_host_ecdsa_keyssh_host_ed25519_key三个文件

执行如下三条命令创建密钥文件:

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

再依次执行服务重启和服务状态查看命令,确认服务启动正常则尝试再次ssh远程

systemctl restart sshd
systemctl status sshd
posted @ 2019-12-19 17:06  Nihaorz  阅读(5683)  评论(0编辑  收藏  举报