ssh connection: ran 'sshd' yet 'port 22: Connection refused'

Specs - Hardware: Software - Galaxy Tab A7 Lite (model name: SM-T220): Android 14 - Raspberry Pi 5 (8GB): Raspberry Pi OS Msg Hello, I was trying to use ssh with these 2 devices: here's what happened: - Android device (host):
pkill sshd
sshd
pkill sshd
sshd
~ $ cat $PREFIX/etc/ssh/sshd_config
PrintMotd yes
PasswordAuthentication yes
Subsystem sftp /data/data/com.termux/files/usr/libexec/sftp-server
~ $ cat $PREFIX/etc/ssh/sshd_config
PrintMotd yes
PasswordAuthentication yes
Subsystem sftp /data/data/com.termux/files/usr/libexec/sftp-server
- Raspberry Pi (client)
alinuxchap@libertus-desktop:~ $ ssh [email protected]
ssh: connect to host 192.168.1.76 port 22: Connection refused
alinuxchap@libertus-desktop:~ $ ssh -vvvvv [email protected]
OpenSSH_9.2p1 Debian-2+deb12u3, OpenSSL 3.0.13 30 Jan 2024
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 192.168.1.76 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/alinuxchap/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/alinuxchap/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.1.76 [192.168.1.76] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: connect to address 192.168.1.76 port 22: Connection refused
ssh: connect to host 192.168.1.76 port 22: Connection refused
alinuxchap@libertus-desktop:~ $ ssh [email protected]
ssh: connect to host 192.168.1.76 port 22: Connection refused
alinuxchap@libertus-desktop:~ $ ssh -vvvvv [email protected]
OpenSSH_9.2p1 Debian-2+deb12u3, OpenSSL 3.0.13 30 Jan 2024
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 192.168.1.76 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/alinuxchap/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/alinuxchap/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.1.76 [192.168.1.76] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: connect to address 192.168.1.76 port 22: Connection refused
ssh: connect to host 192.168.1.76 port 22: Connection refused
What I've tried - both devices connected to same WiFi network (I checked the ip address assigned to the Android device by the router in its Wifi Settings); I also checked the router 'dashboard' (the settings you're able to change just by accessing its local ip address) - in Termux - execute whoami and passwd beforehand - see if anything came up in logcat -s 'sshd:*' while connecting (but nothing was outputted for some reason)
Solution:
you'll need to connect to different port
sshd -p 8022
sshd -p 8022
and then on your raspberry pi, connect to it on port 8022...
Jump to solution
3 Replies
treecosia_44893
treecosia_44893OP3mo ago
alinuxchap@libertus-desktop:~ $ ping 192.168.1.76 PING 192.168.1.76 (192.168.1.76) 56(84) bytes of data. 64 bytes from 192.168.1.76: icmp_seq=1 ttl=64 time=98.6 ms 64 bytes from 192.168.1.76: icmp_seq=2 ttl=64 time=17.7 ms 64 bytes from 192.168.1.76: icmp_seq=3 ttl=64 time=313 ms 64 bytes from 192.168.1.76: icmp_seq=4 ttl=64 time=306 ms 64 bytes from 192.168.1.76: icmp_seq=5 ttl=64 time=330 ms 64 bytes from 192.168.1.76: icmp_seq=6 ttl=64 time=352 ms 64 bytes from 192.168.1.76: icmp_seq=7 ttl=64 time=49.3 ms ^C --- 192.168.1.76 ping statistics --- 7 packets transmitted, 7 received, 0% packet loss, time 6008ms rtt min/avg/max/mdev = 17.663/209.519/351.540/136.062 ms
Solution
komo
komo3mo ago
you'll need to connect to different port
sshd -p 8022
sshd -p 8022
and then on your raspberry pi, connect to it on port 8022
treecosia_44893
treecosia_44893OP3mo ago
Thanks, didn't realise for sshd it was as simple as using the '-p' option (identical to ssh) since there wasn't an example of it here: https://wiki.termux.com/wiki/Remote_Access, so I missed that 'test'
Want results from more Discord servers?
Add your server