SSH Ubuntu Touch

I want to SSH my new Ubuntu phone and tried this instruction but it doesn't work. I get "error: device not found" from every single command.


Actually, the only thing you need to do to access your Ubuntu Touch device via SSH is place an authorized_keys file (with a public key of the PC you're using to access the Ubuntu Touch device) in /home/phablet/.ssh/, and enable SSH access via sudo android-gadget-service enable ssh in the Terminal app.

See this answer for an elegant way to get your ssh keys on the device (ignoring the outdated setprop instructions).

Once this is done, you may want to have a way to toggle the SSH server state for extra security while roaming in foreign networks:

  1. SSH into your device: ssh phablet@YOURDEVICEIP
  2. Create a folder for your scripts: mkdir /home/phablet/bin
  3. Fire up nano to create a script: nano /home/phablet/bin/toggle-ssh.sh
  4. Paste the following:

    #!/bin/bash
    if [[ "$(android-gadget-service status ssh)" == "ssh enabled" ]]; then
        sudo android-gadget-service disable ssh
    else
        sudo android-gadget-service enable ssh
    fi
    
  5. Save the script and exit nano.

  6. Make the script executable: chmod +x /home/phablet/bin/toggle-ssh.sh

Now you can easily turn your SSH Server on or off by running: toggle-ssh.sh, as /home/phablet/bin is in the path for your users executables.

Note: If you face permission issues of bash when executing the script from the device terminal app you need to run: bash bin/toggle-ssh.sh