Skip to content

Using a terminal interface (ssh & scp) with a PYNQ board

ssh (secure shell) is a program that allows you to log in to another computer. and scp (secure copy) allows copying of data between computers. Visual Studio Code and MobaXterm are essentially built on top of these programs.

Logging in using secure shell (ssh)

The following instructions work on any Linux-based system including macOS. On Windows use the PowerShell, which is pre-installed on TU/e university-programme laptops.

  • Connect and boot the PYNQ board.

  • Start a terminal

    • On Windows, start a power shell by pressing the Windows key. Type powershell. Press return.
    • On macOS, start a terminal using Spotlight by pressing Command+space. Type terminal. Press return. (Alternatively, navigate to /Applications/Utilities/ and open Terminal.)
    • On Linux, start a terminal from the start menu.
  • When using ssh the prompt tells you who you are and where you are. For example, in the images below kgoossens@TUE31200 (or \Users\kgoossens) means that I am logged in as user kgoossens on computer TUE31200. And student@pynq shows that I am logged in as user student on computer pynq. This is important because when you execute a command such as halt to stop the computer, you want to make sure that you stop the right computer! The user name and computer name or address are also used by the ssh and scp commands to know where to log in and from where to where to copy (see below).

  • To try, log in to the PYNQ board for the first time with ssh student@10.43.0.1. The student password is "student". When you log in for the first time you will be asked about a "fingerprint". Type yes. Log out with logout or exit.

    The fingerprint question in the PowerShell on Windows:
    Log in to the PYNQ board for the first time
    The fingerprint question in the terminal on macOS. Note that you are not asked to confirm the fingerprint when you log in a second time. Log in to the PYNQ board for the first time

  • Log in to the PYNQ board and safely shut down the PYNQ board with sudo halt. Log in to the PYNQ board for the second time and safely shut down the PYNQ board

Copying data using secure copy (scp)

The scp (secure copy) command is used to copy data between your laptop and the PYNQ board, in either direction. On macOS and Linux you can type man scp in the terminal for the manual of scp. You have to type in the PYNQ password before the copying starts. All the scp commands must be executed in a terminal on your laptop.

  • from your laptop to PYNQ:
    • copy file-on-your-laptop to /home/student/file-on-your-laptop
      scp file-on-your-laptop student@10.43.0.1:
    • copy file-on-your-laptop to /home/student/directory/new-name:
      scp file-on-your-laptop student@10.43.0.1:directory/new-name
    • copy directory-on-your-laptop to /home/student/directory/new-directory:
      scp -r directory-on-your-laptop student@10.43.0.1:new-directory
  • from PYNQ to your laptop is similar, just swap the source (now student@10.43.0.1:) and destination, e.g:
    • copy file-on-pynq to file-on-your-laptop:
      scp student@10.43.0.1:file-on-pynq file-on-your-laptop

ssh

Executing commands remotely

  • ssh username@computername command to execute command as username on the computer with name computername. This command first logs you in on the remote computer and then executes the given command.

    The following example shows how to copy a file to the PYNQ board and check that it has been copied. We then remove the test.txt file on the PYNQ board from the laptop by using the remote ssh command ssh student@10.43.0.1 rm test.txt, and check that it has removed with ssh student@10.43.0.1 ls.

ssh

Mounting the PYNQ file system using sshfs

By using sshfs (secure-shell file system) you can show the PYNQ files in a directory on your laptop and directly use them, without logging in or copying. (A disadvantage is that if your SD card becomes corrupt you lose your PYNQ data. But in any case you should take regular backup copies of the important data on your SD card.)

⚠️ Warning

The following are guidelines rather than exact instructions. Only attempt to do this if you are an expert user that is comfortable installing system software. Use at your own peril.

On Linux

  • First, enable internet sharing with the PYNQ board.
  • Then log in to PYNQ board and install sshfs with sudo apt-get install sshfs.
  • Also install sshfs on your laptop with sudo apt-get install sshfs (Ubuntu) or similar package manager.
  • Finally, mount the PYNQ file system by executing sshfs student@[10.43.0.1]: ~/pynq-fs on your laptop.
  • You can now access (read, edit, move, etc.) the files on the PYNQ board by entering the ~/pynq-fs directory on your laptop.

On macOS

  • First, enable internet sharing with the PYNQ board.
  • Then log in to PYNQ board and install sshfs with sudo apt-get install sshfs.
  • Also install sshfs on your laptop from OSXFUSE or with the Brew or similar package manager.
  • Finally, mount the PYNQ file system by executing sshfs student@[10.43.0.1]: ~/pynq-fs on your laptop.
  • You can now access (read, edit, move, etc.) the files on the PYNQ board by entering the ~/pynq-fs directory on your laptop.

See also here.

ssh keys

The ssh, scp, and sshfs commands become much easier to use if you also install ssh keys.