8 min read

Connect to a Remote Server with SSH (Beginner’s Guide)

Nasrul Hasan
Nasrul Hasan
Nasrul Hasan
Cover Image for Connect to a Remote Server with SSH (Beginner’s Guide)

Connect to a Remote Server with SSH

SSH (Secure Shell) is the most commonly used protocol to securely connect to remote servers. It allows you to execute commands, manage servers, and transfer files over an encrypted connection.In this tutorial, you’ll learn:

  • How to install and enable SSH

  • How to connect to a remote server

  • How to set up SSH keys for passwordless login

  • How to copy files securely using SCP


What is SSH?

SSH is a secure protocol that enables encrypted communication between a client and a remote server. It replaces insecure login methods like Telnet and is widely used in Linux servers, cloud instances, and DevOps workflows.


Check if SSH Is Installed

Run the following command on your server:sudo systemctl status sshdIf SSH is installed, you’ll see the service running.


Install and Enable SSH

Install SSH Server (Ubuntu / Debian)

sudo apt-get update
sudo apt-get install openssh-server -y
pgsql

Enable and Start SSH

sudo systemctl enable ssh
sudo systemctl start sshVerify status:sudo systemctl status ssh
nsis

Connect to a Remote Server Using SSH

Use the following command from your local machine:

ssh <username>@<ip-address>
xml

📌 Example:

ssh ubuntu@54.12.34.56
nginx

You’ll be prompted to enter the remote server password.

⚠️ Password-based login is not recommended for production environments.


Why Use SSH Keys Instead of Passwords?

  • More secure than passwords

  • No need to enter password every time

  • Prevents brute-force attacks

  • Required for automation (CI/CD, Ansible, GitHub Actions)


Setting Up SSH Keys (Passwordless Login)

Step 1: Generate SSH Key on Local Machine

ssh-keygen -t rsa -b 4096 -C your-email@example.com
css

Press Enter to accept default values.

This generates:

  • Private key: id_rsa

  • Public key: id_rsa.pub


Step 2: Copy Public Key to Remote Server (Recommended)

s
sh-copy-id <remote-user>@<ip-address>
vim

📌 Example:

ssh-copy-id ubuntu@54.12.34.56
applescript

Now try logging in again:

ssh ubuntu@54.12.34.56
nginx

✅ You should log in without a password.


Alternative Manual Method

If ssh-copy-id is unavailable:

  1. Copy public key:

cat ~/.ssh/id_rsa.pub
arcade
  1. Log in to the remote server

  2. Navigate to:

cd ~/.ssh
bash
  1. Create or edit file:

nano authorized_keys
ebnf
  1. Paste the public key and save

  2. Ensure permissions:

chmod 600 authorized_keys
chmod 700 ~/.ssh
bash

Download Files from Remote Server Using SCP

Once SSH is configured, you can securely copy files using SCP.

Syntax

scp <user>@<remote-ip>:<remote-file-path> <local-path>
elixir

Example

scp ubuntu@54.12.34.56:/home/ubuntu/app.log ~/Downloads/
ruby

This downloads app.log from the remote server to your local machine.


Common SSH Use Cases

  • Server administration

  • Cloud instance access (AWS, Azure, GCP)

  • CI/CD deployments

  • File transfers

  • Automation and scripting


Conclusion

SSH is a fundamental skill for anyone working in Linux, Cloud, or DevOps. By setting up SSH keys, you significantly improve security and enable automation-friendly workflows.Now that you know how to:

  • Install SSH

  • Connect securely

  • Enable passwordless login

  • Transfer files

You’re ready to manage remote servers like a pro 🚀


👉 Check out my other blogs to learn more about DevOps and Cloud technologies. Thanks for reading!