Configuring SSH Access to Your Milk-V Duo

When getting a new device offering SSH access, the first thing I want to do, is to enable key based ssh access. This enables me to just go ssh DEVICENAME and get a shell without specifying passwords, usernames and addresses each time.

So of course, when getting my hands on a shiny new Milk-V Duo, was to do exactly that. I have documented the process for your convenience and as a note for future me.

This post explains how you can configure your Milk-V Duo for password less login and configuring your SSH tools to understand a name instead of an IP address.

  • A working Linux development machine
  • Proficienty in using the terminal
  • A Milk-V Duo device attached to your development machine with a USB-C cable with data lines.

During this document, I use the address 192.168.42.1 for the Duo. That may be different for your device, but most likely not.

Some USB-C cables only have power lines, but you need one with data lines as well. Ensure you have that.

The steps are as follows:

  1. Create a SSH key pair on your development machine. (If you already have that, you can skip to step 2()
  2. Copy the public key to the Duo
  3. Configure your development machine for your convenience.

1 Create SSH Key pair

Get a terminal on your development machine and run the command in listing 1 below:

$ ssh-keygen -b 2048 -t rsa
Listing 1: Command to create an ssh pair.

just hit enter to each and every question you get some output like listing 2 :

$ ssh-keygen -b 2048 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mowijo/.ssh/id_rsa): 
Created directory '/home/YOUR_USERNAME/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/YOUR_USERNAME/.ssh/id_rsa
Your public key has been saved in /home/YOUR_USERNAME/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:I3ocv/cTR6A+lvdcTWHxy7gjtbfPXxSZKinyhxba+tU YOUR_USERNAME@YOUR_HOST_NAME
The key's randomart image is:
+---[RSA 2048]----+
|               ..|
|           ..  o+|
|           . ..+o|
|          . . = +|
|      o.S+ +   +o|
|     o +=.O * +.o|
|    . o..* * E o.|
|     .  o.+ E =.o|
|       .oo ... .*|
+----[SHA256]-----+
Listing 2: Sample output from creating an ssh keeper.

You will now be able to see two files in ~/.ssh like listing 3

$ ls -la ~/.ssh
total 16
drwx------  2 YOUR_USERNAME YOUR_USERNAME 4096 May 13 08:25 .
drwxr-x--- 39 YOUR_USERNAME YOUR_USERNAME 4096 May 13 08:25 ..
-rw-------  1 YOUR_USERNAME YOUR_USERNAME 1843 May 13 08:25 id_rsa
-rw-r--r--  1 YOUR_USERNAME YOUR_USERNAME  413 May 13 08:25 id_rsa.pub

Listing 3: Command to create an ssh repair.

2 Copy the Public Key to the Duo

You now need to copy your public ssh keys to the duo. This will allow you to log in to the duo without specifying passwords. That is very convenient later. At a terminal on your development machine, run the commands in listing 4. You may be warned that The authenticity of host '192.168.42.1 (192.168.42.1)' can't be established. and asked if Are you sure you want to continue connecting (yes/no/[fingerprint])?. Answer 'yes' to that and you make your local ssh client remember that your duo is trusted. You may be asked for the password for the Duo multiple times.

$ ssh root@192.168.42.1 mkdir -p /root/.ssh
$ scp -O ~/.ssh/id_rsa.pub root@192.168.42.1:/root/.ssh/authorized_keys
$ ssh root@192.168.42.1 chmod 600 /root/.ssh/authorized_keys
Listing 4: Copying the public ssh key to the duo.

You should now be able to ssh into your duo like in listing without providing passwords by running ssh root@192.168.42.1

If you do the above, you will delete anything previous in /root/.ssh/authorized_keys on your Duo, but if you have anything there, you probably knows what you are doing.

3 Configure Your Development Machine for Your Convenience.

Using your favorite text editor, either create or modify the ~/.ssh/config to contain the text in listing 5.

Host duo
    HostName 192.168.42.1
    User root
Listing 5: Content of ~/.ssh/config

You should not be able to ssh into your by simply do a ssh duo and copying files to it like this scp -O some_file duo:

4 Final Words

If you refills the SD card of your Duo, you need to either include the ~/.ssh folder in your build or repeat this process

The -O option to scp is needed because the ssh server in the standard root image provided is fairly old and the -O forces your, probably, newer ssh client to fall back to the -Old protocol.

Contact Me

Fill out the for below and I will get back to you as soon as I get your message...

...or simply call me on +45 42 73 83 10