{ EDIT: Updated to create the guest account in persistent storage. /var (used previously) is a symlink to /tmp, which is wiped on reboot. }
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 persistent directory and initialize the login profile file:
mkdir -p /home/guest touch /home/guest/.profile
Secure the folder so the guest account cannot delete or alter its login profile
chown -R root:root /home/guest chown root:root /home/guest/.profile chmod 755 /home/guest chmod 644 /home/guest/.profile
To ensure the /home/guest/.profile file survives a firmware update, go to System >> Backup / Flash Firmware >> Configuration tab, enter:
/home/guest/ /home/guest/.profile
… into the list, then click the Save button at bottom-right.
Create a guest user:
echo "guest:x:1001:1001:guest:/home/guest:/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
Make the changes survive firmware updates:
echo "/home/guest/" >> /etc/sysupgrade.conf
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.
DropBear SSH and LuCI Terminal: The guest account (and associated guest password) work for both.