'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)
Solution 1:[1]
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
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | KumaTea |
Solution 2 | Steven Lee |