`shell` command with non-default user

my question is about shell command. In my instance, I would like to delete the ubuntu user and replace it with a new one. There is a way to run multipass shell <name> with non-default user?

At the moment, I create the new user using the cloud-init file

  - vagrant: [custom_user]

  - name: custom_user
    ssh_import_id: foobar
    lock_passwd: false
    primary_group: custom_user
    shell: /bin/bash
    plain_text_passwd: 'custom_user'

Hi @apagiaro - no, not at the moment. The user created by Multipass is needed for all Multipass operations.

You can still create the extra user and SSH directly into that one, but the default user needs to remain, and multipass shell would use it still.

We do plan some improvements of this story in the future, but can’t give you any dates, sorry.

Bit late to answer, but for others struggling with this. You can accomplish this with the following command although the ubuntu user is still needed as multipass commands rely on it.

Quick and dirty

multipass exec INSTANCE-NAME -- sudo su USERNAME

With systemd support

Install systemd-container to get machinectl.

# as root inside the VM 
apt install systemd-container


multipass exec INSTANCE-NAME -- sudo machinectl shell USERNAME@

Please notice the @ in the end of the USERNAME.

1 Like