What’s up guys! Welcome (or welcome back) to the blog. I know part two of our SSL series is next in line, but I wanted to hit pause and drop a quick guide on SSH. Why? Because we’ll be using SSH a lot in upcoming videos, and I want this post to be a solid reference we can always come back to.
In this guide, I’ll break down:
- What SSH is and how it works
- How to use both password-based and key-based authentication
- How to connect using VS Code for a smoother workflow
Let’s get into it.
What Is SSH?
SSH stands for Secure Shell — it's a cryptographic protocol that lets you securely connect to remote machines over a network. Think of it like Remote Desktop (RDP) for Linux servers, but command-line only. It’s perfect for server management and automation.
There are two main ways to authenticate with SSH:
- Password-based – easy but less secure
- Key-based – more secure, preferred for long-term use
Configuring SSH to Allow Password-Based Authentication:
Edit the config file:
- nano /etc/ssh/sshd_config
Find and update these values:
- PermitRootLogin yes
- PasswordAuthentication yes
Save, exit and restart the SSH service:
- systemctl restart sshd
Steps to Use Password-Based SSH:
Make sure the SSH daemon (sshd) is running on the server (this is the server you're remoting into).
- systemctl status sshd
That’s the service listening for connections.
Check that SSH is installed on the client (this is the server you're remoting from):
- apt install ssh
Get the IP address or FQDN of the server (this is the server that you're remoting into):
- ip a
Test basic connectivity (make sure you can ping the server you're trying to remote into from the server you're remoting from) :
- ping <server-ip>
Attempt to connect:
- ssh root@<server-ip>
SSH Key-Based Authentication (The Right Way)
This is the method you want for long-term access and automation. No passwords, just cryptographic magic.
How It Works:
- You generate a private key (stays on your local machine).
- You generate a public key (copied to the server).
- When you connect, the server checks if your public key exists.
- It sends a random challenge.
- Your machine signs it with your private key.
- The server verifies it with the public key. If it matches — you’re in.
How to Set It Up:
On the client (your local machine):
- ssh-keygen -t rsa -b 4096 -C "your_comment_here"
- It saves the key in
~/.ssh/id_rsa - You can leave the passphrase blank or add one for extra security
- ssh-copy-id root@<server-ip>
If you prefer manual:
- Copy the contents of ~/.ssh/id_rsa.pub
- Paste it into /root/.ssh/authorized_keys on the server
Make sure you go back and disable password login — it's no longer needed. You should now be able to SSH into your server using key-based authentication. Just run the command below, and if everything is set up correctly, it should log you in automatically without asking for a password.
- ssh root@<server-ip>
Using VS Code for SSH Access
VS Code makes remote server management smooth. With the Remote - SSH extension, you can:
- Edit server files in a GUI
- Use a built-in terminal
- Leverage extensions and linting tools
Setup Steps (See video for detail):
- Install Remote - SSH Extension in VS Code
- Click the green bottom-left icon → Remote-SSH: Open Configuration File
- Add your server info to the config:
Host ssh-server
HostName (hostname)
User root
IdentityFile /home/admin/.ssh/id_rsa
IdentitiesOnly yes
Make sure the private key is in the right location and VS Code has permission to access it:
- chown admin:admin ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
Click "Connect" from the SSH tab in VS Code. You should be connected, and you’ll see a terminal and file explorer for your server. From here, you can navigate folders, edit configs, and use all your VS Code features.
Final Thoughts
This guide is meant to be a go-to reference whenever we're setting up SSH for our lab environment. If you found this helpful, be sure to subscribe, and drop a comment. As always—stay geeking. Peace!