
- Decide what the new account will do
- Check existing access and the account name
- Create the local account with adduser
- Append the sudo group and verify a fresh session
- Install an SSH public key for the new account
- Choose limited privileges when full administration is unnecessary
- Remove privileges without assuming existing sessions disappear
- Final checks before using the account for server work
- Frequently asked questions
- Sources
To create a regular Ubuntu account and grant sudo access, use adduser, append the account to the sudo group, and verify the result in a new login session. The crucial distinction is between creating an account, authenticating to it and authorizing administrative commands. Success at one step does not prove the other two work.
The examples target a standard Ubuntu Server installation and use deploy as a new local account. Replace that name consistently. Run administrative commands from an existing authorized sudo account or provider console. Keep the original SSH session open until the new account has successfully logged in and run the intended command.
Decide what the new account will do
Separate human administration from unattended application work. A human administrator needs an attributable identity and a recovery path; an application usually needs access to selected files or services. Creating both as unrestricted sudo users would hide that distinction and make later revocation harder.
Check existing access and the account name
whoami
sudo -v
getent passwd deploy
getent group sudo
sudo -v validates your current sudo credentials. If it reports that you are not allowed to use sudo, obtain access through an authorized administrator or console; prefixing more commands with sudo will not fix that. If getent passwd deploy returns an account, inspect it before making changes. It may belong to an existing person, service or centrally managed directory.

Ubuntu commonly uses the sudo group for administrative authorization, as described in the Ubuntu sudo_root manual. A customized sudoers policy can behave differently. Group membership is therefore an input to authorization, while sudo -l is the practical check of the effective policy.
Create the local account with adduser
sudo adduser deploy
getent passwd deploy
id deploy
For a regular new user, adduser guides you through account creation and password entry, normally creates a home directory and initializes it from the configured skeleton files. Exact defaults come from the system configuration; do not assume every server has identical shell, group or directory permissions. The adduser manual describes those defaults and configuration files.
Check that the returned home directory and shell match the intended account. id deploy displays the numerical user/group IDs and memberships. Keep the password out of command-line arguments, shell history and support tickets. If the account only runs a background service, a system account without interactive administrative privileges may be a better fit than this human administrator workflow.
Append the sudo group and verify a fresh session
sudo usermod -aG sudo deploy
id deploy
sudo -l -U deploy
-G sets supplementary groups and -a appends to the existing list. Omitting -a can remove memberships not included in the command. This distinction is explicitly documented in the usermod manual; it matters when an existing account already belongs to application or project groups.
A running login session keeps its existing group credentials. Start a new session, rather than expecting an old terminal to inherit the change. For a local preliminary check, the administrator can open sudo -iu deploy, then run:
whoami
id -nG
sudo -k
sudo -l
sudo whoami
whoami should report deploy. For the standard full-administrator policy, the group list includes sudo, and the final command reports root. Sudo normally asks for the invoking user’s password, subject to local authentication policy. sudo -k invalidates the cached credential timestamp so a previous authentication does not conceal the need to authenticate again.
This verifies local authorization, not network access. Exit the test shell when finished, then test SSH separately. Full sudo access is effectively administrative control of the host; adding a person to this group is not merely permission to manage their own files.
Install an SSH public key for the new account
If the client already has a suitable key, reuse its public half according to your access policy. Otherwise generate a distinct key on the client, use a passphrase and decline any prompt to overwrite an existing key:
ssh-keygen -t ed25519 -f ~/.ssh/deploy_ed25519
scp ~/.ssh/deploy_ed25519.pub admin@SERVER_IP:deploy-login.pub
Replace admin and SERVER_IP with the existing working administrator login and server address. Confirm the server host key through a trusted channel. Only the file ending in .pub is transferred; the private key remains on the client.
In the existing administrator session, the following example assumes the newly created account has home directory /home/deploy and does not yet have an authorized_keys file:
sudo install -d -m 700 -o deploy -g deploy /home/deploy/.ssh
sudo install -m 600 -o deploy -g deploy "$HOME/deploy-login.pub" /home/deploy/.ssh/authorized_keys
Use the actual home directory and primary group from getent/id. The second command replaces its destination: if an authorized_keys file already exists, preserve its existing valid keys and append the intended public key instead. Check ownership and permissions after editing. Uploading a key alone does not override SSH policies such as allowed users, authentication methods or centrally managed authorized keys.
The OpenSSH server manual supplied by Ubuntu documents authorized_keys and the ownership checks used for public-key authentication. From a separate client terminal, test the new account:
ssh -i ~/.ssh/deploy_ed25519 deploy@SERVER_IP
id -nG
sudo -l
sudo whoami
Keep the original session open until this test succeeds. An SSH public key can authenticate login without a login password, while sudo may still require the local account password. Do not enable password-based SSH merely to make key installation easier when a working administrator channel already exists.
Choose limited privileges when full administration is unnecessary
A deployment process or log reader should not automatically receive the same authority as a human administrator. Define the task first and review all ways the account obtains privileges. A narrow rule does not cancel broad access granted by another matching rule or group.
For example, a separate local account named opsreader, which is not a full administrator, could be authorized to read one unit without a pager. Verify command -v journalctl; this example assumes /usr/bin/journalctl. Edit the policy using:
sudo visudo -f /etc/sudoers.d/opsreader
An example rule is:
opsreader ALL=(root) /usr/bin/journalctl -u nginx.service --no-pager
The command path and arguments are deliberately fixed. Avoid broad wildcards, general shells, editors or unrestricted service-management commands when the goal is limited access. Reading these logs can still reveal sensitive application data. Review the sudoers command-matching rules before adapting the example.
sudo visudo -c
sudo -l -U opsreader
A syntax check shows that the configuration parses; it does not prove the overall permission design is safe. Test the intended command from a fresh opsreader session and confirm an unrelated harmless command is denied. If the account also has a broad sudo grant, fix that policy conflict before calling it restricted.
Remove privileges without assuming existing sessions disappear
sudo deluser deploy sudo
id deploy
sudo -l -U deploy
This removes the account from the local sudo group, but separate user-specific rules or external identity policies may still grant access. Existing sessions can retain group credentials, and an already-running root shell is not undone by removing membership. Review and end relevant sessions through the approved administration procedure before considering urgent access revocation complete.
Locking a password is a different operation. sudo passwd -l deploy locks the password, but passwd documentation warns that another authentication token, such as an SSH key, may still permit login. For complete offboarding, review account expiry, keys/certificates, active sessions, scheduled jobs and privileges together.
Before deleting the account or its home directory, preserve required data and check service ownership, cron jobs and files outside the home. Removing a Unix account does not automatically explain or repair every dependency that used its numerical user ID.
Final checks before using the account for server work
Record who owns the account, why its privileges are needed, which public key is authorized and how access will be revoked. Verify SSH and sudo independently, then close the old session only after confirming console recovery remains available. The same account can perform an authorized WireGuard VPN setup or manage a Proxmox test environment; neither task requires sharing one person’s private SSH key.
Frequently asked questions
Does an SSH key remove the sudo password requirement?
No. SSH login authentication and sudo authorization are separate. Check the effective local policy instead of assuming a passwordless SSH login implies passwordless administration.
Why does a new group not appear in the old terminal?
Existing sessions retain their group credentials. Create a fresh login and compare id -nG with the administrator’s account lookup.
Can a narrow sudoers rule restrict an existing administrator?
Not by itself. Review other matching rules and group grants; confirm the full effective policy with sudo -l.
Sources
- Ubuntu adduser manual – local account creation.
- Ubuntu sudo_root manual – Ubuntu administrative access.
- Ubuntu usermod manual – supplementary groups and append behavior.
- Ubuntu sudoers manual – effective policy and command restrictions.
- Ubuntu passwd manual – password locking limitations.
Put this guide to work
Compare the number of websites, resource requirements and who will manage the server.
Compare CPU, memory and storage options for your applications.
Compare physical servers by processor, memory, storage and network requirements.