Uncommenting AuthorizedKeysFile in sshd_config blocks access of multipass to my instance


I just installed a new multipass instance, and I observed that if I uncommnet
#AuthorizedKeysFile ~/.ssh/authorized_keys
then I cannot connect anymore to the instance I created. This happens after a restart of the instance.
Is this a bug? Shouldn’t I uncomment this line? I did it in order to provide keys for ssh. Am I doing something wrong here? It does not look like, but blocking completely the access to the instance is not expected.

Error sample:

multipass info linux1
info failed: ssh failed to authenticate: ‘Access denied for ‘publickey’. Authentication that can continue: publickey’

Please provide any input.


Hi @smecher, the best way to add an SSH key to Multipass instances is to use cloud-init.

Something along those lines is the simplest case:

$ multipass launch --cloud-init - <<EOF
- $( cat ~/.ssh/id_rsa.pub )

As to why your case didn’t work, that path is searched by default, so you don’t need to include it in your config, but more importantly, ~ isn’t expanded to your home directory. See ssh documentation on the the topic.

Thank you! This really helped!