Paymahn Moghadasian
Paymahn Moghadasian

Reputation: 10349

How to change default shell in a GCE VM instance?

I've successfully created and logged into a GCE VM with ssh -i ~/.ssh/google_compute_engine <EXTERNAL IP>.

The VM is running ubuntu 18.04 LTS. I've installed zsh. I've verified that the output of which zsh appears in /etc/shells.

When I try to run chsh -s $(which zsh) I'm prompted for a password and I have no idea what to enter.

When I created ~/.ssh/google_compute_engine (which was created during a gcloud ssh command issued earlier) I didn't enter a passphrase for the ssh key.

How can I change my shell?

EDIT: Here's what I see when I've logged in:

paymahn@paymahn:~$ chsh -s $(which zsh)
Password:
chsh: PAM: Authentication failure

Upvotes: 7

Views: 4458

Answers (5)

Feng
Feng

Reputation: 4048

Don't need to create a password, just use sudo

# for current logged user
sudo chsh -s /bin/zsh "$USER"

Upvotes: 7

jaxon737
jaxon737

Reputation: 159

Add a $(which zsh) to your .profile

Upvotes: 1

user98761
user98761

Reputation: 512

Clarifying/combining existing answers (here's what worked for me anyway):

  1. do sudo passwd $USER, to give yourself a password
  2. then do chsh -s /bin/zsh $USER (without the sudo prefix)

Upvotes: -1

Alioua
Alioua

Reputation: 1776

In GCP VM's they don't come with a password by default so you'll first need to change the password using sudo passwd then you can use the root password for your zsh shell.

Upvotes: 1

Paymahn Moghadasian
Paymahn Moghadasian

Reputation: 10349

Ok, figured it out, kinda. I don't think I had a password set at all. I ran sudo passwd paymahn to create a password and then used the newly created password during the prompt for chsh.

Upvotes: 0

Related Questions