Skip to content

Using ssh keys

Typing in your password when you want to log in or copy something to the PYNQ board is annoying. This can be avoided by creating a so-called ssh key, which proves to the PYNQ board that you are an authorised user that can log in without typing a password. This is especially useful when using git version management.

An ssh key is a private/public key pair. Both keys are on your laptop and the public key is on the PYNQ board.

Generating and installing an ssh key

  • In a terminal on the PYNQ board execute the commands (be careful about the spaces in the second line):
    cd
    [ -d .ssh ] || mkdir .ssh
    chmod go= .ssh
    
  • In a terminal on your laptop generate a ssh key with ssh-keygen and copy it to the PYNQ board. You have to enter the student password for the last two commands.
    ssh-keygen -f .ssh/laptop-to-pynq             # press return three times
    scp .ssh/laptop-to-pynq.pub student@10.43.0.1:.ssh/
    ssh student@10.43.0.1 "cat .ssh/laptop-to-pynq.pub >> .ssh/authorized_keys"
    
  • In a terminal on your laptop add the identity file to your ssh profile by editing the .ssh/config file. This .ssh/config file is the same one as you used for Visual Studio Code, which you can use to edit the file if you wish. Note that the 4 spaces before IdentityFile and the capital letters (e.g. IdentityFile not Identityfile) are important.
    Host pynq
      HostName 10.43.0.1
      User student
      IdentityFile ~/.ssh/laptop-to-pynq
    

You can use Visual Studio Code, vim (in the Powershell) or any other text editor you wish.
Visual Studio Code vim

  • On macOS only, in a terminal on your laptop add the the following line to your .bash_profile (if using bash), .zsh_profile (if using zsh):

    ssh-add --apple-use-keychain ~/.ssh/laptop-to-pynq &> /dev/null
    

  • You can now log in by using ssh pynq instead of ssh student@10.43.0.1. (Similarly for scp.)

Example Windows output

ssh keys on windows
ssh keys on windows

Example macOS output

ssh keys on macos

Connecting to a git repository (e.g. gitlab.tue.nl) from PYNQ

When using git repositories such as gitlab.tue.nl with the PYNQ board you'll need to use ssh keys too. For more details see the git page.