T
Termuxā€¢3d ago
Sicnus

Can ping, but can't ssh into phone anymore. (SSHD Running)

As it says in the topic, I can ping from my desktop to my phone and vice versa but can't ssh from desktop into phone. I can go from phone to desktop (I setup keys) I get connection refused when trying to ssh in.
86 Replies
TomIO
TomIOā€¢3d ago
Please make sure you have specified the correct port. Ports under 1024 are privileged and as such Android does not permit their use by regular apps. Termux's SSHD defaults to port 8022.
Sicnus
SicnusOPā€¢3d ago
Yes I have.
ssh [email protected] -p 8022
ssh [email protected] -p 8022
It's been working fine forever... up until this morning. :/
TomIO
TomIOā€¢3d ago
Fun fact, since Termux is effectively a single user system it actually ignores the username so you can put in whatever you want there.
Sicnus
SicnusOPā€¢3d ago
lmao that's hilarious
ssh 192.168.68.55 -p 8022
ssh: connect to host 192.168.68.55 port 8022: Connection refused
ssh 192.168.68.55 -p 8022
ssh: connect to host 192.168.68.55 port 8022: Connection refused
ping 192.168.68.55
PING 192.168.68.55 (192.168.68.55) 56(84) bytes of data.
64 bytes from 192.168.68.55: icmp_seq=1 ttl=64 time=1.58 ms
64 bytes from 192.168.68.55: icmp_seq=2 ttl=64 time=1.80 ms
^C
--- 192.168.68.55 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.580/1.692/1.804/0.112 ms
ping 192.168.68.55
PING 192.168.68.55 (192.168.68.55) 56(84) bytes of data.
64 bytes from 192.168.68.55: icmp_seq=1 ttl=64 time=1.58 ms
64 bytes from 192.168.68.55: icmp_seq=2 ttl=64 time=1.80 ms
^C
--- 192.168.68.55 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.580/1.692/1.804/0.112 ms
TomIO
TomIOā€¢3d ago
You can try increasing the verbosity ssh -v or -vv, (-vvv also exists but is extremely verbose)
Sicnus
SicnusOPā€¢3d ago
ssh -vvvv 192.168.68.55 -p 8022
OpenSSH_9.6p1 Ubuntu-3ubuntu13.5, 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.68.55 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/sicnus/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/sicnus/.ssh/known_hosts2'
debug3: channel_clear_timeouts: clearing
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.68.55 [192.168.68.55] port 8022.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: connect to address 192.168.68.55 port 8022: Connection refused
ssh: connect to host 192.168.68.55 port 8022: Connection refused
ssh -vvvv 192.168.68.55 -p 8022
OpenSSH_9.6p1 Ubuntu-3ubuntu13.5, 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.68.55 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/sicnus/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/sicnus/.ssh/known_hosts2'
debug3: channel_clear_timeouts: clearing
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.68.55 [192.168.68.55] port 8022.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: connect to address 192.168.68.55 port 8022: Connection refused
ssh: connect to host 192.168.68.55 port 8022: Connection refused
TomIO
TomIOā€¢3d ago
You said you had set up ssh keys? You don't seem to be using those currently.
Sicnus
SicnusOPā€¢3d ago
I have keys setup from Phone -> PC (that works still)
TomIO
TomIOā€¢3d ago
ah
Sicnus
SicnusOPā€¢3d ago
it's only from PC -> Phone that stopped working. :/
TomIO
TomIOā€¢3d ago
SSHD is running in Termux?
Sicnus
SicnusOPā€¢3d ago
yeah I did a ps -ef |grep sshd sec
Sicnus
SicnusOPā€¢3d ago
No description
TomIO
TomIOā€¢3d ago
That sure looks like it's running.
Sicnus
SicnusOPā€¢3d ago
"That's what it's mouth say" šŸ˜‰
TomIO
TomIOā€¢3d ago
How are you running sshd anyway? We usually use sv from the runit package for service management on Termux. Are you using that or are you doing it another way?
Sicnus
SicnusOPā€¢3d ago
I had a .bashrc thingy setup when I log in (from some reddit post someone recommended)
TomIO
TomIOā€¢3d ago
Right, we should probably set it up through sv since that's the way we support it officially.
Sicnus
SicnusOPā€¢3d ago
it's a bash script that checks if it's running and then starts it if it isn't. ahhh ok sorry let me nuke that setup
TomIO
TomIOā€¢3d ago
Oh no worries, you didn't have a way to know.
Sicnus
SicnusOPā€¢3d ago
I nuked that... killed "server" started it back... and started sshd manually
TomIO
TomIOā€¢3d ago
Right. You should be able to just install runit and enable sshd.
pkg up
pkg i runit
sv-enable sshd
pkg up
pkg i runit
sv-enable sshd
You might have to restart Termux once, but it should work immediately.
Sicnus
SicnusOPā€¢3d ago
sv-enable not installed
TomIO
TomIOā€¢3d ago
Is that not part of the runit package? One second, gotta check that.
Sicnus
SicnusOPā€¢3d ago
unable to change to service directory: file does not exist
TomIO
TomIOā€¢3d ago
Ah, sv-enable is a utility script we ship as part of termux-services
Sicnus
SicnusOPā€¢3d ago
šŸ™‚ It's instaled now.
sv-enable sshd however pooped itself fail: sshd: unable to change to service directory: file does not exist
TomIO
TomIOā€¢3d ago
Is that the full output?
Sicnus
SicnusOPā€¢3d ago
yessir sv-enable sshd right?
TomIO
TomIOā€¢3d ago
Should be.
Sicnus
SicnusOPā€¢3d ago
termus-services installed successfully
TomIO
TomIOā€¢3d ago
does echo $SVDIR return anything?
Sicnus
SicnusOPā€¢3d ago
k sec
Sicnus
SicnusOPā€¢3d ago
No description
TomIO
TomIOā€¢3d ago
It should return /data/data/com.termux/files/usr/var/service. And if you run ls $SVDIR that should look something like this.
No description
TomIO
TomIOā€¢3d ago
Okay so we have the service directory.
Sicnus
SicnusOPā€¢3d ago
man you got your propmpt pimped out lol I feel like a hobo
TomIO
TomIOā€¢3d ago
starship, it's a shell agnostic prompt framework. (I also happen to maintain the termux package of it)
Sicnus
SicnusOPā€¢3d ago
ahh nice! So yeah that screenshot seems correct
TomIO
TomIOā€¢3d ago
So you have a $SVDIR/sshd directory?
Sicnus
SicnusOPā€¢3d ago
sicnus@thedungeon:~$ nmap -v 192.168.68.55
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-19 17:33 EST
Initiating Ping Scan at 17:33
Scanning 192.168.68.55 [2 ports]
Completed Ping Scan at 17:33, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 17:33
Completed Parallel DNS resolution of 1 host. at 17:33, 0.01s elapsed
Initiating Connect Scan at 17:33
Scanning 192.168.68.55 [1000 ports]
Discovered open port 22/tcp on 192.168.68.55
Completed Connect Scan at 17:33, 0.12s elapsed (1000 total ports)
Nmap scan report for 192.168.68.55
Host is up (0.011s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.16 seconds
sicnus@thedungeon:~$ nmap -v 192.168.68.55
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-19 17:33 EST
Initiating Ping Scan at 17:33
Scanning 192.168.68.55 [2 ports]
Completed Ping Scan at 17:33, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 17:33
Completed Parallel DNS resolution of 1 host. at 17:33, 0.01s elapsed
Initiating Connect Scan at 17:33
Scanning 192.168.68.55 [1000 ports]
Discovered open port 22/tcp on 192.168.68.55
Completed Connect Scan at 17:33, 0.12s elapsed (1000 total ports)
Nmap scan report for 192.168.68.55
Host is up (0.011s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.16 seconds
TomIO
TomIOā€¢3d ago
Open port 22?
Sicnus
SicnusOPā€¢3d ago
that's odd.
TomIO
TomIOā€¢3d ago
That... shouldn't be possible.
Sicnus
SicnusOPā€¢3d ago
No description
Sicnus
SicnusOPā€¢3d ago
lol? I did something (wrong)
TomIO
TomIOā€¢3d ago
I don't understand how port 22 could even be open. Your phone isn't rooted, right?
Sicnus
SicnusOPā€¢3d ago
Not that I know of gulp
TomIO
TomIOā€¢3d ago
Odd
Sicnus
SicnusOPā€¢3d ago
how do I change the password?
TomIO
TomIOā€¢3d ago
Oh... That could be the issue. Didn't even think of that.
Sicnus
SicnusOPā€¢3d ago
don't tell me account is locked lmao hahaha it is
TomIO
TomIOā€¢3d ago
No, Termux is a single user system so it doesn't have any password.
Sicnus
SicnusOPā€¢3d ago
(I think) oh... I thought it asked for a pass when connecting
TomIO
TomIOā€¢3d ago
We specifically have a fork of the passwd utility just to provide a password for SSH. You can use passwd to set a new one. If that has somehow become unset that would at least explain why you couldn't log in.
Sicnus
SicnusOPā€¢3d ago
ok ideas?
TomIO
TomIOā€¢3d ago
The "password" for Termux gets stored in ~/.termux_authinfo I'm guessing that got messed with or lost somehow. As mentioned, you can use passwd to set a new password.
Sicnus
SicnusOPā€¢3d ago
it's gobbledygook should I just true > $THATFILE
TomIO
TomIOā€¢3d ago
Well it's encrypted... That is your SSH password after all, don't want it sitting there in plaintext.
Sicnus
SicnusOPā€¢3d ago
hehe
TomIO
TomIOā€¢3d ago
passwd
Sicnus
SicnusOPā€¢3d ago
ok I think the account is locked Not sure how to unlock it. passwd -u ?
TomIO
TomIOā€¢3d ago
We don't do that here. Termux doesn't use a password for anything other than SSH authentication.
Sicnus
SicnusOPā€¢3d ago
Just keep getting Permission denied. oh let me -vvvvv now
TomIO
TomIOā€¢3d ago
Maximum is 3 -v's but more doesn't hurt.
Sicnus
SicnusOPā€¢3d ago
lol (It's like mashing a button harder)
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug3: kex_input_ext_info: extension server-sig-algs
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug3: kex_input_ext_info: extension [email protected]
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug3: kex_input_ext_info: extension [email protected]
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug3: kex_input_ext_info: extension server-sig-algs
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Will attempt key: /home/sicnus/.ssh/id_rsa
debug1: Will attempt key: /home/sicnus/.ssh/id_ecdsa
debug1: Will attempt key: /home/sicnus/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/sicnus/.ssh/id_ed25519 ED25519 SHA256:L+X3LbHSGJGRr6tP/ee2dC/QpcvPS2ioEMdOtPy65r8
debug1: Will attempt key: /home/sicnus/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/sicnus/.ssh/id_xmss
debug1: Will attempt key: /home/sicnus/.ssh/id_dsa
debug2: pubkey_prepare: done
debug1: Trying private key: /home/sicnus/.ssh/id_rsa
debug3: no such identity: /home/sicnus/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_ecdsa
debug3: no such identity: /home/sicnus/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_ecdsa_sk
debug3: no such identity: /home/sicnus/.ssh/id_ecdsa_sk: No such file or directory
debug1: Offering public key: /home/sicnus/.ssh/id_ed25519 ED25519 SHA256:L+X3LbHSGJGRr6tP/ee2dC/QpcvPS2ioEMdOtPy65r8
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/sicnus/.ssh/id_ed25519_sk
debug3: no such identity: /home/sicnus/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_xmss
debug3: no such identity: /home/sicnus/.ssh/id_xmss: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_dsa
debug3: no such identity: /home/sicnus/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug3: kex_input_ext_info: extension server-sig-algs
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug3: kex_input_ext_info: extension [email protected]
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug3: kex_input_ext_info: extension [email protected]
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug3: kex_input_ext_info: extension server-sig-algs
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Will attempt key: /home/sicnus/.ssh/id_rsa
debug1: Will attempt key: /home/sicnus/.ssh/id_ecdsa
debug1: Will attempt key: /home/sicnus/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/sicnus/.ssh/id_ed25519 ED25519 SHA256:L+X3LbHSGJGRr6tP/ee2dC/QpcvPS2ioEMdOtPy65r8
debug1: Will attempt key: /home/sicnus/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/sicnus/.ssh/id_xmss
debug1: Will attempt key: /home/sicnus/.ssh/id_dsa
debug2: pubkey_prepare: done
debug1: Trying private key: /home/sicnus/.ssh/id_rsa
debug3: no such identity: /home/sicnus/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_ecdsa
debug3: no such identity: /home/sicnus/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_ecdsa_sk
debug3: no such identity: /home/sicnus/.ssh/id_ecdsa_sk: No such file or directory
debug1: Offering public key: /home/sicnus/.ssh/id_ed25519 ED25519 SHA256:L+X3LbHSGJGRr6tP/ee2dC/QpcvPS2ioEMdOtPy65r8
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/sicnus/.ssh/id_ed25519_sk
debug3: no such identity: /home/sicnus/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_xmss
debug3: no such identity: /home/sicnus/.ssh/id_xmss: No such file or directory
debug1: Trying private key: /home/sicnus/.ssh/id_dsa
debug3: no such identity: /home/sicnus/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:
nothing stands out
TomIO
TomIOā€¢3d ago
That's good.
Sicnus
SicnusOPā€¢3d ago
but still... the fact that ssh is running on port 22 is odd
TomIO
TomIOā€¢3d ago
Yeah... it shouldn't do that or even be able to do that.
Sicnus
SicnusOPā€¢3d ago
I wonder if I changed that somehow?
TomIO
TomIOā€¢3d ago
You can check $PREFIX/etc/ssh/sshd_config
Sicnus
SicnusOPā€¢3d ago
sec cat or ls?
TomIO
TomIOā€¢3d ago
Or nano or vim or whatever. I guess cat? We wanna check if the Port has been modified.
TomIO
TomIOā€¢3d ago
GitHub
termux-packages/packages/openssh/servconf.c.patch at master Ā· termu...
A package build system for Termux. Contribute to termux/termux-packages development by creating an account on GitHub.
Sicnus
SicnusOPā€¢3d ago
I wonder if there is a way I can use my keyboard as input on my phone without sshing in... (it's a pain in the butt for me to type on my phone)
TomIO
TomIOā€¢3d ago
I mean, we could just make a key pair on the phone and use ssh-copy-id to send it over to the PC. Wait no you said you already did that.
Sicnus
SicnusOPā€¢3d ago
no that was from phone -> PC not the other way around. I don't think. I just put pass in. oh... h ere's what's odd too... I normally just SSH to that 8022 I don't have any history of me NOT using it
TomIO
TomIOā€¢3d ago
I have my SSH connection for Termux set up as a Host section in my ~/.ssh/config.
# ssh access for Termux in home network
Host Termux Phone termux phone
# Termux disregards the supplied User since its effectively a single-user system
User ssh
Hostname 192.168.111.3
Port 8022
IdentityFile ${HOME}/.ssh/keys/local/rsa-4096_Termux
IdentitiesOnly yes
# ssh access for Termux in home network
Host Termux Phone termux phone
# Termux disregards the supplied User since its effectively a single-user system
User ssh
Hostname 192.168.111.3
Port 8022
IdentityFile ${HOME}/.ssh/keys/local/rsa-4096_Termux
IdentitiesOnly yes
That way you can just type in ssh termux, or ssh phone. (I actually have this set up for all my hosts, but this is the one for Termux)
Sicnus
SicnusOPā€¢3d ago
I hate to ask this... and I doubt you want to, but I could pop in voice and share screen if that makes this easier. But I get you might be doing a billion other things
TomIO
TomIOā€¢3d ago
Oh right, we have voice channels.
Sicnus
SicnusOPā€¢3d ago
hehe
TomIO
TomIOā€¢3d ago
pkg rei openssh
TomIO
TomIOā€¢3d ago
GitHub
.dotfiles/.config/starship.toml at main Ā· TomJo2000/.dotfiles
My dotfile repo. Contribute to TomJo2000/.dotfiles development by creating an account on GitHub.
Sicnus
SicnusOPā€¢3d ago
This issue was me. I failed miserable I was trying to ssh to the wrong IP address. :GASP:
TomIO
TomIOā€¢3d ago
Starship: Cross-Shell Prompt
Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, Ion, Tcsh, Elvish, Nu, Xonsh, Cmd, and Powershell.
Sicnus
SicnusOPā€¢3d ago
Can you hear me? @#!/bin/env TomIO can you still hear me? thanks again @#!/bin/env TomIO

Did you find this page helpful?