DEV Community

Cover image for Understanding SSH, What It Is? Why We Use It? and How to Get Started?
Khaled Md Saifullah
Khaled Md Saifullah

Posted on

Understanding SSH, What It Is? Why We Use It? and How to Get Started?

You have undoubtedly heard of SSH if you have ever needed to establish a secure connection to a distant server. You will use SSH frequently, whether you are a developer, sysadmin or a hobbyist experimenting with Raspberry Pi.

Let's examine SSH's definition, significance and use in this blog post using real world examples.

What is SSH?

SSH (Secure Shell) is a network protocol that allows you to securely connect to and manage remote systems over an unsecured network.

It provides:

  • Confidentiality: Encrypts your communication so no one can eavesdrop
  • Authentication: Verifies that you’re connecting to the right server
  • Integrity: Ensures your data isn’t altered during transfer

Simply put SSH is like a secure tunnel between your computer and another machine.

Why Do We Use SSH?

Here are the most common use cases:

  • Remote Login: Access your server’s shell from anywhere
  • File Transfer: Securely copy files using scp or sftp
  • Port Forwarding / Tunneling: Securely forward ports (useful for databases or apps behind firewalls)
  • Automation: Run scripts or deploy apps remotely

In short: SSH is the gateway to remote system management.

How to Use SSH

Most systems (Linux, macOS even Windows with PowerShell or WSL) come with SSH pre installed.

  1. Basic SSH Command
ssh username@hostname
Enter fullscreen mode Exit fullscreen mode

username: your remote server’s username
hostname: the IP address or domain name of the server

Example

ssh root@192.168.1.10
Enter fullscreen mode Exit fullscreen mode

This will connect to the server at 192.168.1.10 using the root account.

  1. Connect with a Custom Port

If your server’s SSH runs on a non default port (not 22), specify it:

ssh -p 2222 user@myserver.com
Enter fullscreen mode Exit fullscreen mode
  1. Copy Files with SCP
# Copy file from local to server
scp myfile.txt user@server:/home/user/

# Copy file from server to local
scp user@server:/home/user/file.txt .
Enter fullscreen mode Exit fullscreen mode
  1. Generate and Use SSH Keys

For passwordless authentication generate an SSH key

ssh-keygen -t rsa -b 4096
Enter fullscreen mode Exit fullscreen mode

This creates a public/private key pair. Copy your key to the server

ssh-copy-id user@server
Enter fullscreen mode Exit fullscreen mode

Now you can log in without typing your password each time

  1. Run a Command Without Logging In

Sometimes you just want to run a single command remotely

ssh user@server "uptime"
Enter fullscreen mode Exit fullscreen mode

This will show how long the server has been running.

Real World Examples of SSH

Managing a Cloud Server
Connect to your AWS EC2, DigitalOcean Droplet or VPS

ssh ubuntu@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Tunneling to a Database

Forward a remote database port to your local machine

ssh -L 3307:localhost:3306 user@server
Enter fullscreen mode Exit fullscreen mode

Conclusion

One of the most effective tools available to developers and system administrators is SSH. It's an essential ability for everything from automating deployments to login onto a distant computer.

Try connecting to a Raspberry Pi or a test server on your local network if you're just getting started. SSH will eventually become a natural part of your workflow.

Top comments (0)