GoAdmio Command Line: permitrootlogin with /go/permitrootlogin

/go/permitrootlogin lets the root user log in over SSH from an IP address you choose. GoAdmio's hardened SSH configuration restricts root login, so this command adds an exception for a trusted IP address, or for a /24 range, and can remove it again. It works in two steps: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Allow root SSH login from one IP address
/go/permitrootlogin 203.0.113.10

Options

Argument Required Default Notes
ip Yes — An IPv4 address, an IPv4 range written as x.x.x.0/24, or an IPv6 address. See Accepted addresses.
--delete No Off Removes the address from the list instead of adding it.

Examples

# Allow a single IPv4 address
/go/permitrootlogin 203.0.113.10

# Allow a whole /24 range
/go/permitrootlogin 203.0.113.0/24

# Allow an IPv6 address
/go/permitrootlogin 2001:db8::1

# Remove an address
/go/permitrootlogin 203.0.113.10 --delete

# List the addresses that are currently allowed
sudo sqlite3 /var/lib/sqlite/ssh.db "SELECT IP, datetime(TimeStamp,'unixepoch') FROM SSH WHERE Directive='PermitRootLogin'"

Output

Outcome What you get
Address added IP <ip> added successfully. This IP is now allowed to access the server.
Address removed IP <ip> deleted successfully.
The server’s own address Cannot block server IP address. Exit status 1. Nothing is changed.
Not a valid address Invalid IP "<ip>". Exit status 1. Nothing is changed.

The confirmation appears as soon as the database is updated. The SSH configuration is rebuilt in the background afterward, so root login from the address may start working a few seconds later.

The command does not check whether the address was already listed. Adding it again, or removing one that isn’t there, still prints the success message.

Log

Each run appends one line to /var/log/go/permitrootlogin.log:

[Nov 21 12:00:00]# permitrootlogin 203.0.113.10

See the full reference at /go/permitrootlogin and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *