Description

Router refused to accept SSH connection with an error message, "connection refused".  When all of the necessary configuration is present, this issue may be caused by a missing config file for sshd process.

Symptoms

When the user tries to connect to the router via SSH, a "RST" packet is seen instead of "SYN, ACK" from the router, followed by a "connection refused" message on the console.

Solution

  1. Checked the basic configuration, if SSH is allowed on this router for that user.

  2. Restarted the sshd process, which did not clear the issue.

  3. Went to the file system and discovered there is a missing file.

In Junos, when starting /usr/sbin/sshd process from shell, if you are not missing any folders, it will start. Otherwise, it will return the error message shown below:

In this case, it returned missing "/var/etc//sshd_conf"

labroot@test-re0> start shell

root@test-re0% /usr/sbin/sshd

/var/etc//sshd_conf: No such file or directory. <-- Missing file
 

Expected file contents in a working scenario:

Subsystem netconf /usr/libexec/ui/netconf
PermitRootLogin yes

The solution is to delete the ssh configuration on the router and reapply it back to get the sshd_conf contents pushed once again.