KumaTea
KumaTea

Reputation: 640

How to change default shell of OpenWrt?

The default shell of OpenWrt is ash, but I would like to change it to fish.

When I ran chsh -s /usr/bin/fish (the absolute path of fish), it returned -ash: chsh: not found.

The I changed the first line of /etc/passwd from:

root:x:0:0:root:/root:/bin/ash

to:

root:x:0:0:root:/root:/usr/bin/fish

I could't login again (wrong password), and the system log showed:

authpriv.warn dropbear[14288]: User 'root' has invalid shell, rejected


Is there any other way to change the default shell?

(By the way, I am using a popular fork of OpenWrt instead of the official, but it doesn't seem to be the reason of this problem)

Upvotes: 4

Views: 8939

Answers (2)

Steven Lee
Steven Lee

Reputation: 51

chsh -s /usr/bin/fish is correct. But openwrt doesn't have chsh command installed. You need to run opkg install shadow-chsh first to install the chsh command. Then run chsh -s /usr/bin/fish Finally, run echo $SHELL to see if the replacement is successful.

Note that the above operations require root privileges to run.

Sorry for my poor English, hope you can understand.

Upvotes: 5

KumaTea
KumaTea

Reputation: 640

There are two ways to solve this. You can either:

Add /usr/bin/fish to /etc/shells

This solution is provided by @glenn-jackman above in the comments.

Or:

Replacing dropbear by openssh-server

I've figured out another way: if you happen to have openssh-server installed, I would recommend you to use it as default following this tutorial.


And remember to change the first line of /etc/passwd to:

root:x:0:0:root:/root:/usr/bin/fish

Upvotes: 1

Related Questions