SSH How-to: type CLI terminal commands into your phone from your Linux computer

I thought it was perhaps not an evidence to all on how to ssh into the phone.
To ease terminal command typing, to ease copy-paste, to solve things, it is useful being able to do it into a computer. Very handy and faster.
So here is a simple how-to. Feel free to complete/comment.

This is for Linux machines as I don’t know how it goes in Windows or Macos.
edit: @gaidheal indicated Powershell + some module to install, can be used in Windows.

USB

On the phone side:

  • Go into the settings and open Developer Tools
  • Tick Developer Mode
  • Tick Remote connection
  • Enter a password, click “Save” + enter code
  • Look at the USB IP address (usually 192.168.2.13)
  • You can close the page and the settings.

Plug the phone to the computer and tick “developper mode”

On the computer side:

  • Open a terminal

  • Depending on your useranme, type either:

    ssh defaultuser@192.168.2.13 (or the USB IP address you found earlier instead of 192.168.2.13)

    or

    ssh nemo@192.168.2.13 (or the USB IP address you found earlier instead of 192.168.2.13)

    If you ignore your username (nemo or defaultuser), just open a terminal window. The username will be written in the prompt. (Terminal app just appeared in the app grid when you enabled Developer Mode)

  • Enter the password you entered in the phone in the Developer Tools page

    You are now into your phone.

  • To exit and come back into your computer’s shell, type:

    CTRL-D

    or

    exit

WIFI

If you want to connect without cable but through wifi:

  • Connect the phone’s wifi
  • Connect your computer
  • Look at the WLAN address in the Settings Developer tools page
  • Follow the same procedure but replace the USB IP address by the WLAN address.
11 Likes

If you’re on the same network you can ssh into it without usb.
secondly powershell in windows supports ssh, you may need to install module for it though.

1 Like

Thanks for pointing. Will add more details about that.

To log in without having to type the password from a Linux host:

    $ ssh-keygen -t rsa

Use the default file locations and leave the password empty (provided you are the only root on your computer).

    $ ssh-copy-id defaultuser@IP

Type the depeloper password one last time. After that public-key authentication should work.

Now you can become root on your Jolla and copy ~defaultuser/.ssh/authorized_keys to ~/.ssh. After that

    $ ssh root@IP

should also work without asking for a password.

7 Likes

Thanks, Very handy!
Security oriented people might wish only using that for defaultuser and not for root?

Older users will still be nemo as the user. I know my devices are still nemo@x.x.x.x

2 Likes

Yes right, thanks, I added.

nice description. it worked like this with all my sailfish os i had until it stopped working in xperia 10 III. there the connection is not set up and the computer doesn’t see a network-device upon connection oth the phone. not nice this …

My 5 cents in this lovely topic:
In linux, you can create (or edit) the file ~/.ssh/config and add the following:

Host 37
    Hostname 192.168.0.37
    User defaultuser
        
Host 215
    Hostname 192.168.2.15
    User defaultuser

where:

  • 37 is the wifi IP - set static on mobile or edit your DHCP settings to give a static ip on the mac of your mobile
  • 192.168.0.37 is the IP your mobile has
  • defaultuser is the username you use in SailfishOS

The same goes for “215” , which I use it when I connect my mobile with my pc.

After you save the file simply type:

ssh 37

and you connect to your mobile

cheers

3 Likes