Having to log-in to the Services >> Terminal each time you start it is a pain. But bypassing that password authentication opens a major security hole.
By default, using /bin/login -f root in luci-app-ttyd (under Services >> Terminal >> Config >> Command field) creates a major local security hole: anyone on your LAN can bypass LuCI entirely, point their browser to http://<router_ip>:7681, and drop straight into an unauthenticated root shell.
Let’s fix both of those problems.
Create a guest user:
echo “guest:x:1001:1001:guest:/var:/bin/ash” >> /etc/passwd
Register the User Group:
echo “guest:x:1001:” >> /etc/group
Set the guest account password:
passwd guest
Follow the prompts to enter the password for the guest account.
Under System >> Software, install sudo.
Grant sudo permissions (with password use) to the guest user:
echo “guest ALL=(ALL) ALL” > /etc/sudoers.d/guest
Secure the Permissions File:
chmod 0440 /etc/sudoers.d/guest
Set up auto-login to the guest account: Under Services >> Terminal >> Config >> Command field … enter:
/bin/login -f guest
Now, when you start Terminal, it will auto-login to the guest account.
If you try to do anything that requires sudo, such as:
sudo uci show network
… it will prompt you for the guest account password. Sudo remembers the password for a period of time, so you can then perform further sudo actions without having to re-enter the guest password.
If you need to do sudo work, you can type:
sudo -i
… enter the guest account password, and when you’re done, type:
exit
… which will drop you back to the guest account.
How It Works in Practice
Auto-Login: When you open the LuCI Terminal page, it will drop you straight into a command prompt (under the guest account) instantly without prompting for a username or password. Running whoami (if you’ve got that package installed) will show you are guest.
Safe LAN Exposure: If anyone snoops on port 7681 across your local network, they are entirely locked inside a restricted user environment with no rights to alter firewall rules, Wi-Fi configs, or packages.
Elevating Privileges: When you need to run an admin command, prefix it with sudo or drop to a root shell with sudo -i.