SSH keys for Ubuntu 24.04 and 26.04
SSH (Secure Shell) lets you manage your VPS over a secure connection. We recommend using an SSH key instead of your account password to log in.
First, read which user to connect as and keep your existing access to the VPS. Then choose one of the following methods. You do not need to use both.
- Option 1. Termius (recommended) - create and upload a key through the app.
- Option 2. PowerShell on Windows 11 - built-in Windows commands, with no additional apps.
After either method, proceed to the shared verification and next steps.
Why use an SSH key?
An SSH key pair consists of two parts: the private key stays on your device, while the public key is added to the VPS. During login, the SSH client proves to the server that it holds the private key without sending it over the network.
- Protection against brute force: a modern Ed25519 key is practically impossible to guess by brute force. If you disable password login after verifying your key, automated password guessing can no longer be used to log in over SSH.
- Convenience: you do not have to enter your VPS account password every time. You can add one key to several of your own servers.
- Access control: create separate keys for your computer and phone. If you lose a device, remove its public key from your servers.
A passphrase protects the private key itself and is different from your VPS account password. We recommend setting one. Never send the private key to the server, publish it or give it to anyone else.
Preparation: which user should you connect as?
Managing 3X-UI AUTO NGINX requires root, the Linux administrator with full system access. SSH connections usually use the root username.
If your hosting provider prohibits direct root login, use the account it provided (for example ubuntu). Add and verify the key for that exact account. Once you have logged in successfully with the key, obtain root privileges with sudo -i, as described below. You do not need to change SSH settings to allow direct root login.
Do not lose access to your VPS
First, make sure you can log in using your existing method. Keep that SSH session open until you verify a new login. If your hosting provider offers a VPS console in its control panel, make sure it is accessible.
Option 1. Termius (recommended)
Termius is an SSH client for Windows, macOS, Linux, iOS and Android. It keeps your server list and keys in one app, lets you connect in a few taps and transfers files over SFTP. You can create a key and add it to your server without entering terminal commands.
The free Starter plan is sufficient for this task. Its main limitation is that storage is local, with no automatic synchronization of servers and keys across devices. Synchronization is available on paid plans. Compare plans.
1. Add your server and verify login
- Install Termius from the official website or your phone's app store.
- Open Hosts → New Host and enter your VPS IP address, the username
root, SSH port (usually 22) and the password supplied by your hosting provider. If direct root login is disabled, use your own username instead ofroot. - Save the host and connect. On your first connection, compare the server key fingerprint with the provider's information or the VPS console if available. Do not accept an unexpected fingerprint change without investigating it.
- Make sure the terminal opens and keep that connection open.
2. Create a key
- Open Keychain, the key storage area.
- Choose New key → Generate key. On a phone, key creation may be available through the
+button. - In Label, enter a recognizable name, such as "My laptop".
- Set Key type to Ed25519.
- Set a Passphrase for the private key and store it in your password manager.
- Click Generate & save.
If you already have an SSH key, you can import it into Keychain using Import from key file instead of creating a new one. Select the private key file only on your own device; do not send it to the VPS.
3. Upload the public key to the VPS
- In Keychain, open the menu for the key you created (right-click on a computer) and choose Export to host. On a phone, this option may be in the Share menu after a long press on the key.
- Click Select Host and choose the VPS you added. Confirm the export. Enter your server account password if requested.
- Termius connects to the VPS and adds the public part of the key to
~/.ssh/authorized_keysfor the selected user. The private part stays in the app. - In the host settings, check that the new key is selected in the Key field (in some versions, under SSH ID → Key).
4. Verify key-based login
Without closing the old session, remove the saved account password from the host settings (keep it separately) and open a new SSH connection with the selected key. If Termius asks for the VPS password, do not enter it during this test: check the key export and assignment first. A prompt for the key's own passphrase is fine.
If successful, the VPS terminal opens without requesting your account password. Proceed to the shared verification section below.
Option 2. PowerShell on Windows 11
This method uses the built-in Windows SSH client and does not require Termius.
1. Verify normal login
On your computer, in PowerShell:
ssh root@YOUR_VPS_IP
Here and below, substitute your VPS address. If your provider gave you a different account, replace root with its username (for example ubuntu). If SSH uses a non-standard port, add -p PORT after ssh in the connection commands.
Keep the first SSH connection open.
2. Create a key pair on your PC
Open a second PowerShell on your computer (not the VPS terminal) and check whether you already have a key:
Test-Path "$env:USERPROFILE\.ssh\id_ed25519"
If the result is True, a key already exists. Use it and its matching .pub file if available, or choose another name for a new pair. Do not overwrite an existing key: it may provide access to other servers.
If the result is False, prepare the directory and create a new pair:
New-Item -ItemType Directory -Force "$env:USERPROFILE\.ssh" | Out-Null
ssh-keygen -t ed25519 -a 64 -f "$env:USERPROFILE\.ssh\id_ed25519"
You will be prompted to choose a passphrase for the private key. We recommend setting one and saving it in your password manager. Two files will be created:
id_ed25519- the private key. Do not send it to the server.id_ed25519.pub- the public key that can be added to your VPS.
3. Add the public key to your VPS
On your PC, in PowerShell:
Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub" | ssh root@YOUR_VPS_IP "umask 077; mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"
If you do not log in as root, use the same account as in step 1. If your key file has a different name or SSH uses a different port, change those values as well.
The command transfers only the public key over SSH, creates the ~/.ssh directory and appends the key to authorized_keys. Existing keys are not deleted. Directory permissions 700 and file permissions 600 restrict access by other regular users. If the command finishes without errors, do not repeat it, as that would create a duplicate key.
4. Verify a separate key-based connection
Open another PowerShell on your PC:
ssh -o ControlPath=none -o IdentitiesOnly=yes -o PreferredAuthentications=publickey -o PasswordAuthentication=no -o KbdInteractiveAuthentication=no -i "$env:USERPROFILE\.ssh\id_ed25519" root@YOUR_VPS_IP
Substitute your username, address, port and key file as needed. This command verifies key-only login without falling back to password authentication. On success, the Ubuntu terminal opens. You may need to enter the key passphrase, but not the VPS password.
Shared verification and next steps
If the new key-based login succeeds, check your username with whoami. If login fails, do not close your original session. Check the VPS address, username, selected key, and permissions on its ~/.ssh directory (700) and authorized_keys file (600).
Obtain root privileges to manage the project
If whoami already returns root, nothing else is needed. If your provider gives you access through a regular user with sudo privileges, run on the VPS:
sudo -i
Verify:
whoami
The result should be root. You can now launch the installer and run the server commands in the getting started guide. When reconnecting as a regular user, run sudo -i again.
What about the SSH password?
Our installer does not disable password login, to avoid locking you out of the VPS. As long as the server accepts passwords, attackers can still try to guess them even if you personally use a key.
After verifying key-based login from all required devices, we recommend disabling password login. The dedicated guide covers manual configuration, a ready-to-run script, verification and safe rollback. Keep the working SSH session open until verification is complete.
Keep a protected backup of your private key. Termius's free local storage is not a substitute for a backup: losing your device or reinstalling the app could leave you without your key.
How to remove an added key
To undo the setup, use the remaining SSH session or another working access method. As the user whose key you added, open:
nano ~/.ssh/authorized_keys
Delete only the line containing the relevant public key and save the file. Leave other keys and SSH settings unchanged. Before removing it, make sure you still have a working way to log in.
Enhanced VPS security · Getting started
Attribution and use of materials
© 2026 xPROMSx contributors · 3X-UI AUTO NGINX
Our material may be copied and distributed under the GNU GPL-3.0-only license, provided the attribution and link to the original are retained.
Original source: https://xpromsx.github.io/3x-ui-auto-nginx/guides/ssh-keys/