Software & AppsOperating SystemLinux

How To Set Login and Password for Multipass Instance in Ubuntu VM

Ubuntu 7

In this article, we will delve into the process of setting up a login and password for a Multipass instance in an Ubuntu Virtual Machine (VM). Multipass is a lightweight VM manager for Linux, Windows, and macOS. It’s used to create and manage Ubuntu instances.

Quick Answer

To set a login and password for a Multipass instance in an Ubuntu VM, you need to access the instance using the multipass shell command followed by the instance name. Once inside, you can set the password for the "ubuntu" user using the sudo passwd ubuntu command.

Prerequisites

Before we begin, ensure that you have Multipass installed on your system. If not, you can download it from the official Multipass website.

Accessing the Multipass Instance

To set up a login and password, you first need to access the Multipass instance. Here’s how to do it:

  1. Open your terminal or command prompt.
  2. Type multipass list and press Enter. This command will display a list of your Multipass instances.
multipass list

The multipass list command provides a list of your instances, showing their names, states, and IP addresses.

Logging into the Multipass Instance

To login to the instance, use the multipass shell command followed by the name of your instance.

multipass shell <instance name>

Replace <instance name> with the name of your instance. This command will log you into the instance.

Setting up the Password

Once you’re inside the instance, you can set up a password for the “ubuntu” user. Here’s how:

  1. Type sudo passwd ubuntu and press Enter.
sudo passwd ubuntu

The sudo passwd ubuntu command is used to change or set the password for the “ubuntu” user. sudo is a prefix that allows you to execute commands with administrative privileges, while passwd is the command used to change a user’s password.

  1. You’ll be prompted to enter a new password. Type your desired password and press Enter.
  2. You’ll be asked to confirm the password. Re-enter the password and press Enter.

Now, you have successfully set up a password for the “ubuntu” user. You can use this username and password to log in to the instance.

Troubleshooting Connection Issues

If you encounter a “ssh connection failed” message, this might be due to a problem with the host configuration. You can resolve this by checking the hosts.ics file in Windows at C:\WINDOWS\System32\drivers\etc\hosts.ics. Look for any duplicate entries and delete the last ones.

If the issue persists, try connecting to the instance via SSH using the private key. Here’s how:

  1. Open your terminal or command prompt.
  2. Type the following command and press Enter:
ssh ubuntu@<vm-ip-address> -i /var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa

Replace <vm-ip-address> with the IP address of your VM. This command allows you to connect to the VM using SSH.

In conclusion, setting up a login and password for a Multipass instance in an Ubuntu VM involves logging into the instance, setting a password for the “ubuntu” user, and troubleshooting any connection issues that may arise. By following these steps, you can successfully set up your Multipass instance.

Can I set a different username for the Multipass instance?

No, the default username for the Multipass instance is "ubuntu" and cannot be changed.

How can I create a new Multipass instance?

To create a new Multipass instance, you can use the command multipass launch followed by the desired instance name. For example, multipass launch my-instance.

Can I set a password for a different user besides “ubuntu”?

Yes, you can set a password for any user by using the sudo passwd <username> command, replacing <username> with the desired username.

How can I delete a Multipass instance?

To delete a Multipass instance, you can use the command multipass delete followed by the instance name. For example, multipass delete my-instance.

Can I access the Multipass instance from another computer on the same network?

Yes, you can access the Multipass instance from another computer on the same network by using the IP address of the instance. You can find the IP address using the multipass list command.

Can I change the password for the “ubuntu” user after setting it?

Yes, you can change the password for the "ubuntu" user by using the sudo passwd ubuntu command again and following the same steps to set a new password.

Leave a Comment

Your email address will not be published. Required fields are marked *