How to ssh into SFOS

Coul a host entry for ssh solve this part of your problems?

Add this to .ssh/config on you laptop/computer:

Host phone
  Hostname xperiaxa2
  User defaultuser

The connect with ssh phone

This works on most networks for me, sometimes i need to use the IP, but in these cases I just use USB then usually. I also have an entry for this:

Host phoneusb
  Hostname 192.168.5.15
  User defaultuser
2 Likes

This is technically off-topic; but i can already do ssh defaultuser@Xperia10III with no config at all. Presumably it is my router picking up the hostname and adding it to dns, should be pretty normal…

3 Likes

@thigg : …and where in the phone is the name ‘Xperia10III’ set?
until now I always logged into the phone with ‘ssh defaultuser@192.168.0.x’, [enter] , then terminal asked me for password, then i was logged in. The host address (x) i read from Settings/developer tools.

edit: Does this also work, if the IP-address the phone gets from the router, changes sometimes?

This is the hostname, you can either see it in your router or in /etc/hostname. And it works, when the ip changes. Also for maximum convenience i would recommend using a ssh key.
For that, do on your computer:

ssh-keygen
ssh-copy-id phone

this deploys your newly generated key on your phone. (you can simply enter an empty password for ssh-keygen, if you deem files on your pc as secure)

afterwards you can just use ssh phone without ever typing your password again (from this user on this computer).
Also rsync, scp,… Work with all of these (keys and host entries)

2 Likes

I didn’t have a ‘~/.ssh/config’ file on my computer (Ubuntu Linux), so I created one. But it doesn’t work. Computer reports: ‘ssh: Could not resolve hostname xperia10-dualsim: Temporary failure in name resolution’ , doesn’t find the IP-address of the phone.

So in your instance the computer doesn’t ‘know’ the device.

I set up a fixed ip address for devices like my PCs and phone on the router, then give them a name in my hosts file.
You can then ssh username@xperia10xiii
eg:
192.168.1.266 xperia10xiii

1 Like

I have not yet a real router, I use one of my Sailfish phones with its mobile access point as main internet gateway and have no other.

Connected to this access point are a TP-Link DAP-1325 WLAN range extender, via cable a printer, and another Sony and a Volla Sailfish phone also via WLAN.

So can I configure all this routing in the one phone thats the access point?
The TP Link has no option for such settings on it’s config page, it’s too simple.

Another way to set a static ip address is by defining it in the client.
There is a risk in a more ‘normal’ network of ip addresses being duplicated if the router provisions the same ip as defined by another client, but you should be ok.
In your case I would make a note of your phone ip (from the Developer tools section of Settings) and use that. I would also do the same on your computer and as many devices as possible in order to avoid the possibility of duplication.

I haven’t done this on a linux system (years ago I used to set static ips on my Windows devices, but since then I’ve used the router where required), but I assume something like this might work:

I would make backups of any files before editing them just in case
There’s a guide here

‘‘I didn’t have a ‘~/.ssh/config’ file on my computer’’

Not even in /etc?

@ric9k
No, the only file I have is :
/etc/ssh/ssh_config

and an empty folder:
/etc/ssh/ssh_config.d/

edit:
’ ~/.ssh/known_hosts’ is the only file in ~/.ssh/ , no other file present.

Hmm, not sure but ymmv depending the ssh version?
Maybe a hidden file or hidden dir in your home?
You are using ssh as usual user, aren’t you?
Do

find /home/[your dir name]/ -iname “*ssh*”

give nothing either?

There comes nothing. After a second, again input prompt, nothing else.

Hmm, knowledge lack at this point…
Have no computer atm to test/search.
But search the web,

how to use ssh config file

seems to give good fruits!

1 Like

This content in ‘~/.ssh/config’ works as long the phone has this dynamic IP address:

Host volla
Hostname 192.168.0.3
User defaultuser

So I have only to type ‘ssh volla’ and immediately there comes the password prompt. Thats very good, but i fear it will stop to work as soon the phone will get another dynamic IP address anytime later. But a first step is done. Thank you very much! :smiling_face_with_three_hearts:

Previous experiments with:
Host volla
Hostname VollaPhone
User defaultuser

did NOT work. (VollaPhone is the phones network name entered in 'Settings/WLAN/pulldown/advanced/Hostname )

1 Like

make an alias on the machine you use to to ssh….and CTRL R can also do wonders…

1 Like

A locally-assigned hostname can not automatically be addressed on the network unless the router/DNS server/DHCP server handles it.. Most devices tell the DHCP server (usually your router) its hostname, and the router must have the functionality to set up an entry in its DNS table for that hostname and the dynamically-assigned IP adress. Many basic routers do not do this.

Some routers, even if they do not automatically fill in its DNS table, let you manually assign an arbitrary hostname to a MAC address, so that the device with that MAC is always adressable using the hostname you decide.

Unfortunately, I cannot give any kind of instructions for this, you have to tey figure it out.

3 Likes

I use fixed IP address in the phone and an entry in ~/.ssh/config on my Linux computers. The ssh keys are also in ~/.ssh . So no router functionality necessary.

1 Like

Using static adresses is also a solution, of course.