Skip to content
Calin Crisan edited this page Jan 20, 2020 · 16 revisions

Topics

About

SSH can be used to remotely log in to the device. If you're familiar with Linux, you'll find the command line offered by thingOS suitable for tweaking the OS, debugging or simply exploring the internals.

Credentials

Username & Password

By default, root is the only user that is available for login (with its admin alias). At boot, its password is empty. You should make the necessary steps to set a root password as soon as you've booted up your system. See User Accounts for more details.

SSH Key

The SSH server uses /etc/sshd_config as configuration file, which sets the unique authorized keys file path to /data/etc/ssh_authorized_keys.

First, ensure you have your SSH private/public key pair, on your laptop (assuming you run Linux):

$ test -f ~/.ssh/id_rsa.pub || ssh-keygen

Then transfer your public key to the device:

$ ssh-copy-id root@your_device

Alternatively, just copy the contents of your laptop's ~/.ssh/id_rsa.pub to the device's /data/etc/authorized_keys.

Command Line

The thingOS command line is a regular shell based on bash. Most binaries are however provided by BusyBox, so you may find some incompatibilities/limitations when compared to a fully fledged Linux system.

You can play around with the system but keep in mind that:

  • the root and boot partitions are read-only
  • you can mount the root and boot partitions read-write, but a firmware update will discard any of your changes
  • you may actually make changes to /usr, /var/lib and /var/log; the mounted overlay filesystems allow you to

See Partitions for more details.

SSH Client

You may want to run remote commands from within thingOS using the ssh command, on another machine. You can automate the login process using SSH keys as follows (run these commands on the device):

  1. Generate a key pair for your device:

     # ssh-keygen -f /data/etc/ssh_id_rsa
    
  2. Configure the SSH client so that it reads the identity from the newly created private key:

     # echo "IdentityFile /data/etc/ssh_id_rsa" >> /data/etc/ssh_config
    
  3. Tell your SSH client to store known hosts data on the writable partition:

     # echo "UserKnownHostsFile /data/etc/ssh_known_hosts" >> /data/etc/ssh_config
    
  4. Copy your device's public key and add it to your other machine's ~user/.ssh/authorized_keys file:

     # cat /data/etc/ssh_id_rsa.pub
    

    Alternatively, you can use ssh-copy-id for this transfer:

     # ssh-copy-id -i /data/etc/ssh_id_rsa user@otherhost
    
  5. Test the setup; it should run the ls -l command remotely without asking for a password (will ask you to confirm the authenticity of the remote host once, though):

     # ssh user@otherhost ls -l
    

SFTP

The SFTP functionality is enabled by default in thingOS. Using the correct credentials, an SFTP client will allow you to browse the files on your device:

$ sftp root@yourdevice
Clone this wiki locally