Q: Had to setup new my Linux laptop, now can't ssh to Sailfish phone no more. What can I do?

On the Linux laptop I had SSH passwordless login by SSH key pair and everything was fine for a long time. But the laptop’s batteries were bloated so I had to change them, so BIOS settings erased, so Windoof booted, Win** found unexpected file system, started unasked to ‘fix’ it and so destroyed my Linux kernel.

Now I have a new Linux installation (and a new battery), but now ssh login on the SFOS phone is no more possible:

andrea@andrea-Voom-Laptop-Max:~$ ssh x10
ssh: connect to host 192.168.0.4 port 22: Connection refused
andrea@andrea-Voom-Laptop-Max:~$ ssh defaultuser@192.168.0.4
ssh: connect to host 192.168.0.4 port 22: Connection refused
andrea@andrea-Voom-Laptop-Max:~$ 

Neither passwordless nor ‘old style’ by username and password.

How can I - on the phone as devel-su - delete all SSH key pair stuff to become able to install it new?

Thanks for any hint!

There seems to be many assumptions here, and missing information.
Do you still have the required private keys (those not ending in .pub) on your laptop? And everything in ~/.ssh basically?
Have you configured sshd on your phone to allow only specific IPs/users or anything like that?
Is your phone completely untouched by the recent laptop desaster?

Why would you want to do that?
Anyhow: No devel-su required. Just cd ~/.ssh and delete what you want there.

1 Like

That doesn’t look like key issues, it looks like wrong IP - like another device with no ssh sever.
Run ssh with -v and see what is really going on before guessing on remedies.

Once in a blue moon i need to reboot my phone or router for odd breakages like this. But i assume you have done basics like that before asking?

And also, didn’t you have the same issue before?
Yes, yes you did: SSH + SFTP access to phone lost

2 Likes

@ohnonot Content of ~/.ssh/* of the old crashed Linux is still available including the old keys (pub and private), also config. (Did install the new Linux onto a new SSD and kept the old one in the drawer)

@attah IP addresses are the same as before and manually set from a paper list in my documentation. Also the ~/.ssh/config is copied from the old crashed system. The ssh keys for one Xperia10 and the Volla are generated new and working fine. But the new generated ssh key and also the ‘normal’ login for the other Xperia 10 don’t work.

This is the error message when trying to ssh to the X10 using -v modifier:

andrea@andrea-Voom-Laptop-Max:~$ ssh -v defaultuser@192.168.0.4
OpenSSH_8.9p1 Ubuntu-3ubuntu0.3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/andrea/.ssh/config
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 *
debug1: Connecting to 192.168.0.4 [192.168.0.4] port 22.
debug1: connect to address 192.168.0.4 port 22: Connection refused
ssh: connect to host 192.168.0.4 port 22: Connection refused
andrea@andrea-Voom-Laptop-Max:~$ 

With the key files from the old Linux copied to the new system it also doesn’t work.

Are you sure, you haven’t changed ssh configuration on your phone? Another reason for not being able to connect would be, that your sshd is listening on a different port

I didn’t change anything on the phone. It was the laptop that crashed, so there the Linux is fresh installed from zero onto a new SSD. While I did so, the phone was unused and untouched, and after this the login to to THIS phone doesn’t work any more but login to 2 other SFOS phones does work fine again.

On your host, after trying to connect, what does:

arp -n

say? Do you see a MAC address of the phone’s IP?
and:

nmap -Pn -p 22 -n 192.168.0.4

(On my X this fails very often, much more than with XA2)
If you have terminal access on the phone:

netstat -nlt

(but this you know, right?)

andrea@andrea-Voom-Laptop-Max:~$ arp -n
Adresse Hardware-Typ Hardware-Adresse Optionen Maske Schnittstelle
192.168.0.1              ether   (address)   C                     enxc84d442109a4
192.168.0.2              ether   (address)   C                     enxc84d442109a4
192.168.0.4              ether   70:a6:cc:53:d2:6b   C                     enxc84d442109a4
andrea@andrea-Voom-Laptop-Max:~$ 

The ‘4’ is the phone that doesn’t work.

andrea@andrea-Voom-Laptop-Max:~$ nmap -Pn -p 22 -n 192.168.0.4
Starting Nmap 7.94 ( https://nmap.org ) at 2023-09-07 19:05 WEST
Nmap scan report for 192.168.0.4
Host is up (0.043s latency).

PORT   STATE  SERVICE
22/tcp closed ssh

Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds
andrea@andrea-Voom-Laptop-Max:~$ 
andrea@andrea-Voom-Laptop-Max:~$ netstat -nlt
Aktive Internetverbindungen (Nur Server)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:631                 :::*                    LISTEN     
andrea@andrea-Voom-Laptop-Max:~$ 

That might be correct. I see “filtered” for X very often when it is not filtered. Guess that is because of the wake process.
netstat on the phone. Guess you won’t see port 22 on the list, so, sshd then would be down down…
Anyway, with the port closed, you get “connection refused” and as was said before, “keys” didn’t even come into the game…

1 Like

@attah Yes it’s the same problem as 2 years ago. Now I also tried all suggestions from this time but now it doesn’t help. Some hidden detail must be different but I don’t know what.

edit: From another laptop ssh connection is also not possible. The phone doesn’t listen on port 22, and I have no idea what I can do now. Port 22: connection refused.

Asking the obvious: Is remote access on the phone enabled?

1 Like

Likely differences in firewall configs.

If a firewall defaults to DROP you will see ‘filtered’. If it does a REJECT or there is no firewall (and nothing listening on the port), it will show ‘closed’.

Just to be sure, have you checked in Settings → Developer Mode that “Remote Connection” is still checked?

@sebix : yes

@phklrz : yes

@nephros : I saw this and it looks strange. But have no idea how to turn it on / open it by CLI command.

And
devel-su journalctl |grep -i ssh
?

Don’t think so.
If I ran the command several times as posted above, I get “open” and “host down”. If I add –disable-arp-ping I get “open” and “filtered”. I don’t think that firewall rules are touched by “sleep” and “wake up”, they are much too slow for that. So, I think this happens during “sleep transition”. But this is academic for the original problem… :wink:

This returns nothing, CLI prompt occurs again.

edit:

Now I did by guessing:

Turn SSH access off
Reboot phone
Turn SSH access on again
Check accessibility from laptop

Result: It works again! :star_struck:

Thank you all for helping me!

1 Like

What Linux distribution have you installed?
Asking, because I encountered the same problem with a new Debian 12 some days ago.

Solution was to click on the network dock applets icon to open the network menu.

Screenshot from 2023-09-08 12-38-05

Then, enable the switch corresponding to the phone, sometimes called Xperia something, sometimes Ethernet.

1 Like

I use Ubuntu 22.04 Jammy Jellyfish (x86-64) / Cinnamon 5.2.7 on a 2 year old laptop named ‘InnJoo’.

edit: In my network settings (the same icon on the dock as on your system), there are no settings regarding other LAN or WAN hosts, but only the network adapter settings. IP-Address, subnet mask, gateway, DNS, routes, proxies… nothing else, no other hosts there at my computer. In this setting dialog it’s also possible to install a VPN connection and a lot of other connection types, but currently not in use at the moment on my computer.

edit: nothing else is wrong, there’s a lot, but I didn’t fill in anything there, the defaults work. But I could really find nothing regarding other hosts in the LAN, e.g. Xperia.

1 Like

Sometimes sshserver stops on my phone although ssh connection is enabled in settings, then i get the same error you got. Then i usually deactivate ssh connection and then enable it again and then i can connect

2 Likes