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’
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.
I recently got the same error too. Here is what caused the error:
I launched an instance successfully and logged into it with multipass shell <instance_name>
Then I inadvertently overwrote all the files in ~/.ssh/ of the host computer (not the instance).
All multipass commands with regard to this instance were failing with this same error
Fortunately, I was still logged into the instance and I could log in via ssh ubuntu@<instance_ip> - I had a chance to manually copy my public key into authorized_keys file. Here is how I resolved the issue:
I created a new instance and logged into it.
I copied the only key in ~/.ssh/authorized_keys
I then pasted this key into ~/.ssh/authorized_keys of the first instance.
Problem solved. I could now safely delete and purge the second instance.