Report this

What is the reason for this report?

Unable to ssh into droplet after zsh install

Posted on June 25, 2015

Hey folks,

I installed zsh and now I am unable to ssh into the droplet. Any idea what’s going on? I contacted Support and got the steps below but I got stuck because I can’t edit any file in the recovery mode. I tried vim, emacs and nano but neither one of those commands existed.

I’ll really appreciate any help on this.

Cheers, Fayi

p.s here are the instructions I got from support. 1.) Power off your droplet and change your kernel to the DO-recovery-static-fsck image.

2.) Boot your droplet and access it via the console in the control panel.

3.) Run the command “blkid” and make note of the device with LABEL=“DOROOT” (it should be either /dev/vda or /dev/vda1)

4.) Run the command “mkdir /mnt”, then “mount $DEV /mnt”, replacing $DEV with the device you found in the previous step

5.) Check /mnt/var/log/auth.log to see if it contains information about the issue

6.) If necessary, run the command “sed -i -re ‘s;^(root.*:)[^:]+$;\1/bin/bash;’ /mnt/etc/passwd” (or just edit /mnt/etc/passwd directly to use the correct shell)

7.) Power off your droplet, change the kernel back to the original, and reboot

Are you able to log in successfully at that point?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

It is possible that if your users default shell is not set properly it can prevent you from logging in. In addition to the recovery kernel support has the ability to boot your droplet to a recovery ISO which provides a full live Debian environment where you should be able to mount your disk r/w. I’d recommend updating your ticket and requesting that support boot your droplet to the recovery ISO so you can investigate further.

Hello, @fayimora

I’ll recommend you to reach to our support team in cases where the recovery console or the recovery iso image are stuck or not responsive.

Run the following commands to mount your filesystem:

blkid mkdir /mnt mount /dev/vda1 /mnt # Assuming /dev/vda1 is the correct device from the blkid output

Since you’re unable to use text editors like vim, you can use sed to directly modify the shell for the root user back to /bin/bash:

sed -i -re 's;^(root.*:)[^:]+$;\1/bin/bash;' /mnt/etc/passwd

You can check whether the /etc/passwd file has been modified by listing it:

cat /mnt/etc/passwd | grep root

Ensure that the root user has /bin/bash set as the shell.

After making the changes, unmount the filesystem and power off the droplet:

umount /mnt poweroff

At this point, you should be able to SSH back into your droplet with the root user using Bash instead of Zsh.

If you need to re-enable Zsh later, you can first verify everything works in Bash and then carefully reconfigure Zsh, ensuring that you have proper fallbacks in place in case of misconfiguration.

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.