Score:0

systemctl hangs when starting sshd, but "/usr/sbin/sshd -D -f /etc/ssh/sshd_config &" works

cn flag

CentOS 7. Here's /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 $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

Everything that is uncommented in sshd_config:

HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
AuthorizedKeysFile.ssh/authorized_keys
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
usePAM no # Had to change it to no from yes because the connection was dropping right after successfull auth
X11Forwarding yes
Subsystemsftp/usr/libexec/openssh/sftp-server

Anything else I'm happy to provide if needed. Appreciate your help!

Michael Hampton avatar
cz flag
What's in the logs?
Score:0
in flag

Looks like you have a typo there in your sshd_config

Subsystemsftp/usr/libexec/openssh/sftp-server

Should be

Subsystem sftp /usr/libexec/openssh/sftp-server

And this

AuthorizedKeysFile.ssh/authorized_keys

Should be

AuthorizedKeysFile .ssh/authorized_keys

Furthermore, do a syntax check of your config

sshd -t 
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.