This page looks best with JavaScript enabled

Create ssh key pair ubuntu on raspberry pi

 ·   ·  โ˜• 1 min read

    Creating ssh key pair

    Make sure authorization key writable on the remote

    chmod 600 /home/ubuntu/.ssh/authorized_keys
    

    Generate the key on the client

    ssh-keygen
    

    For our purposes you can accept all the defaults.

    If you havenโ€™t changed any setting, by default you will find your newly created key pair in your home directory under .ssh subfolder.

    • Copy SSH Public Key to Raspberry PI

    Once you have generated the key pair, you will need to copy the public key to Raspberry by issuing the following command:

    ssh-copy-id -i ~/.ssh/id_rsa pi@<YOUR_RASPBERRY_IP>
    

    where:

    • id_rsa is the name of SSH key you generated in the previous step
    • pi is Raspberry user
    • <YOUR_RASPBERRY_IP> is the IP of your Raspberry PI box

    Modify the values according to your specific environment.

    You will need to keep the private key on your workstation in order to be able to connect to Raspberry.

    Test ssh connection to Raspberry PI

    You should now be able to connect to Raspberry without a password, try the following command:

    ssh -i ~/.ssh/id_rsa pi@<YOUR_RASPBERRY_IP>
    

    If everything is fine, you are in and ready to go !!!

    Now we can create a file rpi.sh and use:

    ssh ubuntu@<REMOTE_IP>
    

    by default it uses -i ~/.ssh/id_rsa as the key

    Run this to login to the pi


    Ohidur Rahman Bappy
    WRITTEN BY
    Ohidur Rahman Bappy
    ๐Ÿ“šLearner ๐Ÿ Developer