-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Where to find SSH keys for multipass? #913
Comments
Hi @garethr, if you installed via snap, it should be in |
@ricab apologies, this was on macOS and installed via Homebrew. |
Keys are located in |
Mmm, interesting. I don't find that directory, but I have found: This contains However, trying to use the key doesn't appear to work: $ multipass ls
Name State IPv4 Release
aroused-grebe RUNNING 192.168.64.3 Ubuntu 18.04 LT
$ ssh [email protected] -i ~/Library/Application\ Support/multipass/client-certificate/multipass_cert_key.pem
[email protected]: Permission denied (publickey). |
@garethr instead of using Multipass's keys, it's better to bootstrap your instances with Also see our docs for a suggestion on how to use I'll close this issue for now. |
I've been trying to use cloud init files but you still need to pass an |
I am having the same issue - There is no way to access a Multipass VM directly using SSH? |
@gerboland is right, keys are located under I was able to access the VM using the private key.
That allowed me to use multipass VMs with
The only issue is to manage root rights for the private key (i.e. sudo) |
Actually instead of finding out the public key that recognized by multipass instance, we could simply append the public key of local user (e.g. ~/.ssh/id_rsa.pub) to the file ~/.ssh/authorized_keys on multipass instance. They we can login to the instance with ssh command: |
The ubuntu user works for me using the keys in /var/root which require sudo, eg:
|
JFYI location of id_rsa on Windows: |
Hi then used Later found a comment above suggesting Thanks |
On the Windows 10 platform, using PowerShell:
To SSH directly into a Multipass virtual machine:
Here's a screenshot of Microsoft Terminal showing it in action: |
I created a PowerShell module to simplify this for Windows 10 users. You will need to run PowerShell "As Administrator" in order to use this, since the SSH key is in a protected area of the Windows filesystem. Find Module on PowerShell Gallery
Install Module On Your System
Use Command to Establish SSH Session
NOTE: The |
For future readers -
ssh_authorized_keys:
- <your_ssh_key> and create a vm using this config multipass launch --cloud-init cloud-init.yaml Once launched, you can get the ip using |
For me, I must have |
this was helpful. thanks! adding this. in case we want to copy id_rsa to other files, ensure that it has wheel |
@oleg-andreyev FYI: This location appears to have changed with
|
fwiw, sshuttle could be used like so: sudo sshuttle -r ubuntu@$(multipass list --format yaml | yq '.charm-dev[0].ipv4[0]') 0/0 \
--ssh-cmd 'ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking no" -i /var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa' |
Thanks to @sed-i's comment and this page , was able to do something similar with vanilla ssh ssh -i user_key ubuntu@$(multipass list --format yaml | yq '.testvm[0].ipv4[0]') -o StrictHostKeyChecking=no What tripped me up was the The relevant snippet looks like this #cloud-config
# vim: syntax=yaml
groups:
- docker
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
gecos: Default User
groups: users,admin,wheel,docker
shell: /bin/bash
ssh_import_id:
- gh:pythoninthegrass
ssh_authorized_keys:
- ssh-rsa AAAAB3Nza<SNIP>= ubuntu |
To append the ssh key post-factum: INSTANCE="primary"
PUBKEY="$(cat ~/.ssh/id_rsa.pub)"
multipass exec -n "$INSTANCE" -- bash -c "printf '%s\n' '$PUBKEY' >> ~/.ssh/authorized_keys"
|
For those who installed multipass on arch from AUR: |
On Windows this is now at: |
I'm able to access a multipass VM using the built-in
shell
command, but would like to also be able to access directly using SSH, mainly to use multipass with automation tools which connect via SSH. Where can I find the SSH key to connect to the VM?The text was updated successfully, but these errors were encountered: