How to Connect to Ubuntu Server via SSH
Secure Shell (SSH) is the standard protocol for securely logging into and managing remote Linux servers via the command line. This guide provides a quick, step-by-step walkthrough on how to initiate a basic SSH connection to a remote Ubuntu Linux server from your local machine. You will learn the necessary command syntax, how to handle the initial security fingerprint prompt, and how to connect using either a password or an SSH key pair.
Prerequisites
Before you begin, ensure you have the following information: * The
IP address or domain name of your
remote Ubuntu server. * A valid username on the remote
server (such as ubuntu or root). * The
password associated with that username, or an
SSH private key authorized on the server.
Your local operating system (Windows, macOS, or Linux) must also have an SSH client installed. Modern versions of Windows (via PowerShell/CMD), macOS, and Linux have a built-in SSH client ready to use.
Step 1: Open Your Terminal
Open the command-line interface on your local computer: * Windows: Open PowerShell or Command Prompt. * macOS: Open the Terminal app. * Linux: Open your preferred terminal emulator.
Step 2: Run the SSH Command
To initiate the connection, use the basic ssh command
followed by your username and the server’s IP address, separated by an
@ symbol.
ssh username@server_ip_addressFor example, if your username is ubuntu and your
server’s IP address is 192.168.1.50, you would type:
ssh ubuntu@192.168.1.50Press Enter to run the command.
Step 3: Accept the ECDSA Key Fingerprint (First Connection Only)
The first time you connect to a new Ubuntu server, your local machine will display a security warning stating that the authenticity of the host cannot be established. It will ask if you want to continue connecting.
Type yes and press
Enter.
This adds the server to your local list of known hosts
(~/.ssh/known_hosts), and you will not see this warning
again unless the server’s IP address changes or the SSH keys on the
server are regenerated.
Step 4: Authenticate and Log In
Depending on how your Ubuntu server is configured, you will authenticate using one of two methods:
Method A: Password Authentication
If password authentication is enabled, the terminal will prompt you for the remote user’s password.
Type the password and press Enter. Note: For security reasons, no characters or asterisks will appear on the screen as you type your password.
Method B: SSH Key Authentication (Alternative)
If your server requires an SSH key for authentication rather than a
password, you must specify the path to your private key file using the
-i flag:
ssh -i /path/to/private_key.pem username@server_ip_addressIf your private key is protected by a passphrase, you will be prompted to enter it now.
Step 5: Successful Connection
Once authenticated, your terminal prompt will change to show the
username and hostname of your remote Ubuntu server (for example,
ubuntu@ubuntu-server:~$). You are now logged in and can
execute command-line instructions directly on the remote machine.
To close the SSH session and return to your local terminal at any time, type:
exit