vim /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.service
Wants=sshd-keygen.service
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -d -D $OPTIONS // 添加-d
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
然后重启服务
systemctl daemon-reload
systemctl restart sshd
查看系统日志
journalctl -xe -u sshd -f
在另开一个终端,使用ssh登录不同用户就会看到debug信息
-- Subject: Unit sshd.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sshd.service has finished starting up.
--
-- The start-up result is done.
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:cNmWmzJVrXuESZXn75p+5vaYwcRdTgn3A+EorcM+k2Y
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: private host key #2: ssh-ed25519 SHA256:hH55TxiE+wxkXJGnbipDvFdyHZSAkV5XZxM22L3pIkc
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: rexec_argv[0]='/usr/sbin/sshd'
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: rexec_argv[1]='-d'
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: rexec_argv[2]='-D'
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: Set /proc/self/oom_score_adj from 0 to -1000
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: Bind to port 22 on 0.0.0.0.
Jul 02 15:26:52 prophet268 sshd[27633]: Server listening on 0.0.0.0 port 22.
Jul 02 15:26:52 prophet268 sshd[27633]: debug1: Bind to port 22 on ::.
Jul 02 15:26:52 prophet268 sshd[27633]: Server listening on :: port 22.
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: Server will not fork when running in debugging mode.
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
Jul 02 15:28:58 prophet268 sshd[27633]: rexec line 42: Deprecated option RSAAuthentication
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: sshd version OpenSSH_7.4, OpenSSL 1.0.2k-fips 26 Jan 2017
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: inetd sockets after dupping: 3, 3
Jul 02 15:28:58 prophet268 sshd[27633]: Connection from ::1 port 45036 on ::1 port 22
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: private host key #0: ssh-rsa SHA256:R8GeBmf5SzJ22r7wpGyUuXhYQnhxPyVNZHQShdjAldI
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:cNmWmzJVrXuESZXn75p+5vaYwcRdTgn3A+EorcM+k2Y
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: private host key #2: ssh-ed25519 SHA256:hH55TxiE+wxkXJGnbipDvFdyHZSAkV5XZxM22L3pIkc
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: Client protocol version 2.0; client software version OpenSSH_7.4
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: Local version string SSH-2.0-OpenSSH_7.4
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: Enabling compatibility mode for protocol 2.0
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: SELinux support enabled [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: permanently_set_uid: 74/74 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: SSH2_MSG_KEXINIT sent [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: SSH2_MSG_KEXINIT received [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: kex: algorithm: curve25519-sha256 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: kex: curve25519-sha256 need=64 dh_need=64 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: kex: curve25519-sha256 need=64 dh_need=64 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: rekey after 134217728 blocks [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: SSH2_MSG_NEWKEYS sent [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: expecting SSH2_MSG_NEWKEYS [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: SSH2_MSG_NEWKEYS received [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: rekey after 134217728 blocks [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: KEX done [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth-request for user root service ssh-connection method none [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: attempt 0 failures 0 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: reprocess config line 42: Deprecated option RSAAuthentication
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: PAM: initializing for "root"
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: PAM: setting PAM_RHOST to "localhost"
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: PAM: setting PAM_TTY to "ssh"
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth-request for user root service ssh-connection method publickey [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: attempt 1 failures 0 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:TstxdnvVdWV4TzqSNnhHDhTZWzNPoUeTn7DXHgbCVPQ [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: temporarily_use_uid: 0/0 (e=0/0)
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: trying public key file /root/.ssh/authorized_keys
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: fd 4 clearing O_NONBLOCK
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: restore_uid: 0/0
Jul 02 15:28:58 prophet268 sshd[27633]: Failed publickey for root from ::1 port 45036 ssh2: RSA SHA256:TstxdnvVdWV4TzqSNnhHDhTZWzNPoUeTn7DXHgbCVPQ
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth-request for user root service ssh-connection method publickey [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: attempt 2 failures 1 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for DSA SHA256:K1gn5Xw0/Lodi/6sPHlmTsEFulyjSjjlhx4zii6NLiE [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: temporarily_use_uid: 0/0 (e=0/0)
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: trying public key file /root/.ssh/authorized_keys
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: fd 4 clearing O_NONBLOCK
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: restore_uid: 0/0
Jul 02 15:28:58 prophet268 sshd[27633]: Failed publickey for root from ::1 port 45036 ssh2: DSA SHA256:K1gn5Xw0/Lodi/6sPHlmTsEFulyjSjjlhx4zii6NLiE
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth-request for user root service ssh-connection method publickey [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: attempt 3 failures 2 [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for ECDSA SHA256:ITZJ9Rv6EGeKXqjlU1kYwlxshel9fcBb3WnESEmr6KI [preauth]
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: temporarily_use_uid: 0/0 (e=0/0)
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: trying public key file /root/.ssh/authorized_keys
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: fd 4 clearing O_NONBLOCK
Jul 02 15:28:58 prophet268 sshd[27633]: debug1: restore_uid: 0/0
Jul 02 15:28:58 prophet268 sshd[27633]: Failed publickey for root from ::1 port 45036 ssh2: ECDSA SHA256:ITZJ9Rv6EGeKXqjlU1kYwlxshel9fcBb3WnESEmr6KI
Jul 02 15:29:01 prophet268 sshd[27633]: debug1: userauth-request for user root service ssh-connection method password [preauth]
Jul 02 15:29:01 prophet268 sshd[27633]: debug1: attempt 4 failures 3 [preauth]
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: PAM: password authentication accepted for root
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: do_pam_account: called
Jul 02 15:29:02 prophet268 sshd[27633]: Accepted password for root from ::1 port 45036 ssh2
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: monitor_child_preauth: root has been authenticated by privileged process
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: monitor_read_log: child log fd closed
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: temporarily_use_uid: 0/0 (e=0/0)
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: ssh_gssapi_storecreds: Not a GSSAPI mechanism
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: restore_uid: 0/0
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: SELinux support enabled
Jul 02 15:29:02 prophet268 sshd[27633]: debug1: PAM: establishing credentials