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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM