Ssh connection is refused and failing to connect on fedora 37

Ssh connection is refused and failing to connect on fedora 37

Getting connection refused error when connecting another machine 172.158.12.13 from my machine 172.158.12.123 via ssh.

[test1@machine1]$ ssh test2@172.158.12.13
ssh: connect to host 172.158.12.13 port 22: Connection refused

Check whether sshd service is enabled or not,

[test2@fedora]$ sudo systemctl status sshd

service status,

[sudo] password for test2: 
 sshd.service - OpenSSH server daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: man:sshd(8)
             man:sshd_config(5)

Looks like sshd service is disabled, so we need to start the sshd service on the target machine.

[test2@fedora]$ sudo systemctl start sshd

Check again sshd service status,

[test2@fedora]$ sudo systemctl status sshd

service status once started sshd service,

sshd.service - OpenSSH server daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; preset: disabled)
     Active: active (running) since Sat 2023-03-04 08:03:08 IST; 2s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 69094 (sshd)
      Tasks: 1 (limit: 9236)
     Memory: 2.2M
        CPU: 8ms
     CGroup: /system.slice/sshd.service


Still ssh connection is refused and not working,

checking netstat for ssh,

[test2@fedora]$ sudo netstat -plntu | grep ssh
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      69094/sshd: /usr/sb 
tcp6       0      0 :::22                   :::*                    LISTEN      69094/sshd: /usr/sb 

Check PasswordAuthentication parameter in config file /etc/ssh/sshd_config,

# PasswordAuthentication No

Need to set PasswordAuthentication to yes to connect the machine via ssh using user password,

PasswordAuthentication Yes

Now restart the sshd service and try ssh connection again,

[test2@fedora]$ sudo systemctl stop sshd
[test2@fedora]$ sudo systemctl start sshd

Checking ssh connection again,

[test1@machine1] ssh test2@172.158.12.13
test2@172.158.12.13's password:

1 device has a firmware upgrade available.

Last login: Sat Mar  4 08:45:57 2023 from 172.158.12.123
[test2@fedora]$

Finally ssh connection is working as expected.




Python installation

Privacy Policy  |  Copyrightcopyright symbol2020 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^