Skip to content

Secure Shell (SSH)

SSH (Secure Shell) is a protocol that allows you to securely connect to remote machines over a network. In the context of FRI, SSH is used to connect to your robot car remotely, allowing you to access its terminal and files as if you were physically present.

Setting up your SSH keys

SSH keys are a pair of cryptographic keys used for secure authentication. The pair consists of a private key, which you keep secret on your local machine, and a public key, which you can share with remote machines (like your robot car) to allow secure access. This setup process will only need to be done once per computer.

  1. Open a terminal. For terminal setup and a short explanation of the difference between a terminal and a shell, see the dedicated guide: docs/tools/terminal.md.

  2. Check if you have an existing SSH key.

    Examining the contents of the ~/.ssh folder:

    ls -al ~/.ssh
    

    Explanation: ls is the command to list files. The -al flag provides a detailed, organized list of all files, including hidden ones (which start with a dot, like .ssh). The ~/.ssh argument specifies the path to your .ssh directory.

    Check the output of this command for any key file pairs, which will be in a format such as id_ed25519 and id_ed25519.pub, or id_rsa and id_rsa.pub or id_ecdsa and id_ecdsa.pub.

    If you find a keyfile pair, jump to step 4. Otherwise, proceed with generating a new key as described in step 3.

  3. Generate a new SSH key, only if you don't have a key already.

    • Run the following command after replacing the placeholder email with your email:
    ssh-keygen -t ed25519 -C "[email protected]"
    
    • Press [ENTER] twice to accept all the defaults (file name and pass phrase).
  4. Add your ssh key to the ssh-agent.

    The ssh-agent is a program that runs in the background and manages your SSH keys, allowing you to use them without needing to enter your passphrase every time.

    If ssh-agent is not already running:

    • On macOS or linux, run the following command in your terminal:
    eval "$(ssh-agent -s)"
    

    Note: On mac and linux, you can add the command eval "$(ssh-agent -s)" to your bash profile to automatically start the ssh-agent when you open a terminal.

    • On windows, first start the ssh-agent service by running the following command in an elevated powershell terminal (run as administrator):
    Get-Service -Name ssh-agent | Set-Service -StartupType Manual
    Start-Service ssh-agent
    

    Then add your key to the ssh agent: ssh-add ~/.ssh/id_ed25519

    Note: Your ssh key will need to be added to the ssh-agent every time your computer is restarted.

  5. Update your ssh configuration.

    Use the vim editor to update your ssh configuration file on your local computer, which is at the path ~/.ssh/config, to add the lines, replacing the XX with the ID if your car. For example, for car 3 use 03:

    Host *
        ForwardAgent yes
    
    Host orinXX
        User orin
        HostName 10.1.0.1XX
    

    Explanation: The first block, starting with Host *, will ensure that your local ssh key is sent to the car when you connect via ssh, so that you can use git on the car. The second block, starting with Host orinXX, configures your computer to connect to the correct IP address using the given User when you type in the Host name. For example, instead of typing ssh [email protected], you can run the simpler command: ssh orin03.

  6. Add your ssh key to your github account

    Following the github instructions: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

  7. Add your key to the robot car

    Copy your public ssh key to the robot car by running the following command in your terminal, replacing XX with your car's ID:

    ssh-copy-id orinXX
    

    Note: If you get a "ssh-copy-id: command not found" error, you can manually copy the contents of your public key file (usually located at ~/.ssh/id_ed25519.pub) and append it to the ~/.ssh/authorized_keys file on the robot car. You can do this by first connecting to the car using ssh orinXX, then using a text editor like vim or nano to open (or create) the ~/.ssh/authorized_keys file and pasting in your public key.

Connecting to your robot car via SSH

To connect to your robot car, use the following command in your terminal, replacing XX with your car's ID:

ssh orinXX