Score:0

How to setup Multipass VM on Mac and integrate with Vscode to run Linux virtually

de flag

I recently mailed my TA on how to setup Linux on a Mac for a Computer Systems course to which I received the steps highlighted below- (I am stuck in the 6th and 7th step) I have some idea of what is happening like Multipass is used to create a virtual machine that runs on a server and there's no GUI. Also, I understand that ssh will be used to login into the VM. But, I don't understand why do I have to edit the public key in the instance. (You can go through the email and I have highlighted the exact problem I am facing below the email.)


  1. Install Mutipass through: brew install --cask multipass

  2. Find a suitable instance(22.04LTS proffered) and create an instance in Multipass: first run multipass find and look for the 22.04 LTS instance.
    After that, run multipass launch jammy Note here that jammy is the name used to create 22.04LTS instance.

  3. Generate SSH Key Pair on MacBook: Run the ssh-keygen command in your terminal. This will generate a pair of keys; one public (the one you'll share) and one private (the one you keep secure on your device). When you run the command, you'll be prompted to enter a file to save the key, just press enter to save it in the default location, which is usually ~/.ssh/id_rsa.

  4. Get a List of Running Instances: Run multipass list to get a list of all your running virtual machine instances.

  5. Select and Access the Instance: Note the name of your instance (e.g., 'brimming-yak'). Access the shell for your instance by running multipass shell brimming-yak.

6. Edit the authorized_keys File in VM: Inside the shell, navigate to the ~/.ssh/ directory. If it doesn't exist, create it using mkdir ~/.ssh. Use a text editor like nano or vim to edit the authorized_keys file. If it doesn't exist, you can create it with touch ~/.ssh/authorized_keys. Open it in the editor and append your public key (the contents of ~/.ssh/id_rsa.pub on your MacBook) to this file.

  1. Restart the Instance: Exit the shell and restart the instance with multipass restart brimming-yak.

  2. Get the IP Address of the Instance: Use multipass info brimming-yak to get detailed information about the instance, including its IP address.

  3. SSH into the Machine: You can now SSH into the machine from your MacBook terminal using ssh ubuntu@[IP Address of Instance]. Replace [IP Address of Instance] with the actual IP address you got from the previous step.

  4. Set Up VSCode for SSH: Install the "Visual Studio Code Remote - SSH" extension in VSCode. Click on the green box in the lower-left corner of VSCode, then select Remote-SSH: Connect to Host..., and enter ubuntu@[IP Address of Instance]. VSCode will now set up a connection, and you'll be able to use VSCode as if you were working directly on the VM. For detailed instructions, you can refer to the official VSCode documentation.


Now, whenever I try the step7 I get the error- restart failed: ssh failed to authenticate: 'Access denied for 'publickey'. Authentication that can continue: publickey'
I have looked up numerous web articles to try and fix this problem with no success. Is there anything wrong with the steps highlighted that is causing this problem.

Thanks for any help! :)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.