Search code examples
sshgoogle-coralmendel-os

mdt shell does not connect or push ssh key


I cannot connect to my coral devboard via mdt shell over OTG USB-C port after following along here. Initially, I had the mendel 'public device cowardly refusal' issue as outlined in an q&answer here. I used serial console and nmtui to get the devboard on my LAN and I fixed that checking code on my host to match my LAN arrangement (172 instead of 192 block) and that worked to start connection via mdt shell.

Now, when connecting I get the below error about only allowing a single ssh key. I have ONLY connected via screen in serial console since I initially flashed the board. No one has ever ssh'd.

Waiting for a device...
Connecting to undefined-snail at 172.16.1.39
Key not present on undefined-snail -- pushing

Couldn't connect to keymaster on undefined-snail: [Errno 61] Connection refused.

Did you previously connect from a different machine? If so,
mdt-keymaster will not be running as it only accepts a single key.

You will need to either:
   1) Remove the key from /home/mendel/.ssh/authorized_keys on the
      device via the serial console

- or -

   2) Copy the mdt private key from your home directory on this host
      in ~/.config/mdt/keys/mdt.key to the first machine and use
      'mdt pushkey mdt.key' to add that key to the device's
      authorized_keys file.

Failed to push via keymaster -- will attempt password login as a fallback.
Can't login using default credentials: Bad authentication type; allowed types: ['publickey']

The first suggestion points to known authorized_keys. Via serial console, I can see that directory doesn't exist [yet?]...

mendel@undefined-snail:~$ pwd && ls -la
/home/mendel
total 28
drwxr-xr-x 3 mendel mendel 4096 Aug 13 01:11 .
drwxr-xr-x 4 root   root   4096 Feb 14  2019 ..
-rw------- 1 mendel mendel  237 Aug 13 02:01 .bash_history
-rw-r--r-- 1 mendel mendel  220 Feb 14  2019 .bash_logout
-rw-r--r-- 1 mendel mendel 3526 Feb 14  2019 .bashrc
drwx------ 3 mendel mendel 4096 Jul 24 20:51 .gnupg
-rw-r--r-- 1 mendel mendel  807 Feb 14  2019 .profile

The second suggestion about copying the local key via mdt pushkey does not work and repeats the same error message above which I received after mdt shell

macOS Catalina 10.15.6 (19G73). Factory new board flashed with devboard quick start instructions 8/12/2020


Solution

  • can you try using ssh instead of mdt (mdt is just wrapper around ssh)? I believe this is a Catalina problem, Linux and older versions of Mac also works fine, I believe it has to do with their libusb changes. This issue has been reported earlier, here is a quick guide on using ssh:

    Create a id_rsa key on your mac with:

    $ ssh-keygen
    

    This creates a ~/.ssh/id_rsa.pub file on your MAC. You can copy that key over to the board and put the content in ~/.ssh/authorized_keys (you can put multiple keys in this file). After that you can go ahead and disable Password authentication by modifying /etc/ssh/sshd_config and turn PasswordAuthentication from yes to no and restart ssh service on the dev board:

    $ sudo systemctl restart ssh
    

    Then you can start ssh-ing into your board using:

    $ ssh mendel@ip-addr