Skip to content

Register SSH Key Pair

Ana Cristina Franco da Silva edited this page Feb 2, 2021 · 8 revisions

Instead of connecting remotely to your IoT devices using a password, you can use a SSH Key. The motivation for using public key authentication over simple passwords is security. Public key authentication provides cryptographic strength that even extremely long passwords can not offer. With SSH, public key authentication improves security considerably as it frees the users from remembering complicated passwords (or worse yet, writing them down).

Therefore, it is possible:

  1. to add key pairs to the MBP to connect to your IoT devices, or

  2. to generate new key pairs in the MBP for connecting to your IoT devices

To make the execution of the steps clearer to you, the two key pair configurations are shown below.

1. Use Keys from Device and MBP host computer

To start this type of registration, it is needed the Public RSA Key and the Private RSA Key.

  • Public RSA Key (from Device):

    This key should be configured in your IoT device and it is not necessary to provide it to the MBP, since it is not a mandatory property. In case you want to provide it the registration, you can retrieve it from your IoT device, for example, using this:

    > cd ~/.ssh
    > cat ~/.ssh/id_rsa.pub
    

    Then copy the Key, which will be printed in the command prompt and paste it in the Public RSA keydialog input.

    For details of how to configure your device to enable passwordless SSH access, take a look in the raspberrypi.org tutorial.

  • Private RSA Key (from MBP host Computer):

    The corresponding private key will be configured in the MBP host computer. you can find it, for example, on the same folder where the public key was generated by you:

    > cd ~/.ssh
    > cat ~/.ssh/id_rsa
    

    Then copy the Key which will be printed in Command Prompt.

In the MBP, go to Main Navigation > IoT Hardware > Key Pairs, press the ➕ button, fill the properties including the data above, and press Register.

2. Generate a new key pair in the MBP

In the MBP, go to Main Navigation > IoT Hardware > Key Pairs , press the​ 🔧 button , give the key pair a name, and press Generate.

You can :visualize the public key and copy it to the clipboard, or you can download the public key. This should be then configured in your IoT device.

In the device command prompt:

  > cd ~/.ssh
  > nano authorized_keys
  > In authorized_keys press CTRL + O to edit
  > In authorized_keys include the public key generated by MBP
  > In authorized_keys press CTRL + X and Y to save it

Clone this wiki locally