I have the new Termux from Fdroid in my Samsung tablet.
I can use ftp in Termux to connect to my PC
but
I can not use ssh in Termux to connect to my PC… ssh hostname
it says … Connection refused on port 22
I used the openssh package and I have openssh-tools installed
I know Termux uses port 8022, but that is for its server sshd. I only want the client, so I should not have to start the server daemon.
ssh -p 8022 hostname does not work either
Termux has no /etc/services file, and there is no config file in ~/ssh.
Is it maybe dns that is not working? But it works for ftp… I can do ftp hostname?
Do you have a ~/.ssh/ folder? (never mind see below)
I do - but I don’t try and configure that in the TermUX shell… i.e. I hate using the wonky onscreen keyboard to do ANYTHING…
I enable sshd (simply “sshd”) then remote from another machine, into my Galaxy S9+…
I have a config file in there too… But I just “include” a subfile just for Android
I can’t ping stuff on my network by name - i.e. no internal DNS. Avahi doesn’t seem to work either…
My ~/.ssh/config, that works everywhere else (MacOS, FreeBSD, Linux on x86_64 and armhf / aarch64) doesn’t “work” in TermUX - mainly 'cause Avahi (AKA “zeroconf” and “bonjour”) doesn’t seem to be supported in TermUX / Android…
It does sound odd that FTP works, by hostname, but not ssh…
I can’t edit my /etc/hosts file in Android… So I have to use IP addresses… But I have nicknames set in my SSH config :
╭─u0_a440@localhost ~/.ssh
╰─➤ uname -a
Linux localhost 4.9.118-23733710 #1 SMP PREEMPT Thu Jul 21 17:52:31 KST 2022 aarch64 Android
╭─u0_a440@localhost ~/.ssh
╰─➤ cat config
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
User x
# Include ~/bin/configs/home
# Include ~/bin/configs/horizon
# Include ~/bin/configs/mrwa
#Include ~/bin/configs/eni
# Include ~/bin/configs/homeo
Include ~/.ssh/homeo
Yes I have ~/.ssh. There are 3 files in it , but no config file
I can
ping trinity
ftp trinity
but not
ssh trinity
and there is no config file in ~/ssh.
OK - question answered… Can you make it? Where does it save known_hosts to? Folder just needs 0700… all files in it should be 0600…
Hmm - shouldn’t that be ~/.ssh (not ~/ssh)?
Yes .ssh, my typo
I have 0700 for ~/.ssh
0600 for its contents
but there is no known-hosts and no config in ~/.ssh
the files are
authorized_keys
id_ed25519
id_ed25519.pub
I made an empty config file … no difference.
My /etc/hosts is there in Android… all it contains is localhost
If I try to start ‘sshd’ I get
$sshd
sshd: no hostkeys available -- exiitng
I dont need sshd , but there is something wrong there too.
That is the clue
The problem was in the PC
/etc/ssh/sshd_config
had ListenAddress set to my local net.
That disables all other sources… such as my modem’s wifi net.
SOLVED
Have to be careful with username… Termux defaults to u0_a304 which does not exist in the PC
It now has a known_hosts file .
That is not quite the full story. I then changed the PC from Void to MX, and the ssh from Android failed. This time it was because MX had ufw enabled. I had to allow port 22 for it to work .
Then when I move the PC back to Void, it fails… the key for trinity is wrong. I have to delete known_hosts for it to work again.