Root Login
You will need to know your server’s public IP address and the password for the “root” user’s account.
Connect To Your Server with SSH
In order to connect to a remote Linux server via SSH, you must have following:
- User name: The remote user to log in as. The default admin user, on most Linux servers is
root
- Password and/or SSH Key: The password that is used to authenticate the user that you are logging in as. If you added a public SSH key to your server when you created it, you must have the private SSH key of the key pair (and passphrase, if it has one)
- Server IP address.
SSH Client Software
PuTTY (Windows): A free SSH client that can run on Windows, and is available for download on the PuTTY Download Page. putty.exe
is the SSH client, and puttygen.exe
should also be downloaded if you want to use SSH keys.
SSH Login as Root
Run putty.exe;
Configure the Connection
To properly configure the the SSH connection in putty, ensure that the following settings are set:
- Host Name (or IP address): Enter your server’s IP address here
- Port: 22 (default)
- Connection Type: SSH (default)
Initiate the Connection
To initiate the connection, double-click on the session name, and accept the security alert (this will only appear the first time you connect to a server).
Authenticate
Follow these steps to complete the login process:
- At the
login as
prompt, enterroot
- At the
Password prompt
, enter the password that was emailed to you (copy and paste it) - At the
(current) UNIX password
prompt, paste in the temporary password again - At the
Enter new UNIX password
prompt, enter a strong password - At the
Retype new UNIX password
prompt, enter the same strong password that you just entered
Don’t forget the new password that you set.
Create a New User
Once you are logged in as root :
In this example we’ll create a new user called “demo”:
adduser demo
Next, assign a password to the new user (again, substitute “demo” with the user that you just created):
passwd demo
Enter a strong password, and repeat it again to verify it.
Root Privileges
By putting the word sudo
before each command, This will allow our normal user to run commands with administrative privileges.
As root
, run this command to add your new user:
gpasswd -a demo wheel
Add Public Key Authentication (Recommended)
Generate a Key Pair will increase the security of your server by requiring a private SSH key to log in.
To generate a new key pair:
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/localuser/.ssh/id_rsa):
Copy the Public Key
Use ssh-copy-id
If your local machine has the ssh-copy-id
script installed, you can use it to install your public key to any user that you have login credentials for.
ssh-copy-id demo@SERVER_IP_ADDRESS
Your public key will be added to the remote user’s .ssh/authorized_keys
file.
Configure SSH Daemon
Open the configuration file with your text editor as root:
vi /etc/ssh/sshd_config
To disable remote root logins, we need to find the line that looks like this:
#PermitRootLogin yes
Replace ‘yes’ by ‘no’ and save.
Reload SSH
Type this to restart SSH:
systemctl reload sshd
Test the new configuration
ssh demo@SERVER_IP_ADDRESS
sudo command_to_run