Your First Virtual Linux Lab: A Simple Setup Guide

Published: (February 7, 2026 at 11:54 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Setup SSH Server on Ubuntu

# Update package list
sudo apt update

# Install OpenSSH server
sudo apt install -y openssh-server

# Enable and start the service
sudo systemctl enable ssh
sudo systemctl start ssh

Installs the SSH server and ensures it starts automatically on boot.

Verify the Service

sudo systemctl status ssh

You should see active (running).

Check the VM’s IP address:

ip a

You’ll find a line similar to:

inet 192.168.45.100/24

Use this IP to connect from Windows.

Connect from Windows PowerShell

ssh alok@192.168.45.100

On the first connection you’ll be prompted:

Are you sure you want to continue connecting (yes/no)?

Type yes to trust the VM’s SSH fingerprint (it will be saved to known_hosts).

Copy Your Windows Public Key to Ubuntu

Windows PowerShell does not include ssh-copy-id, so use a one‑liner:

type $env:USERPROFILE\.ssh\id_ed25519.pub |
  ssh alok@192.168.45.100 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

This appends your Windows public key to ~/.ssh/authorized_keys on the VM.

Test Passwordless Login

ssh alok@192.168.45.100

You should be logged in without a password.

On the Ubuntu side you can verify the authorized keys:

cat ~/.ssh/authorized_keys

You’ll see entries such as:

ssh-rsa ... (older key)
ssh-ed25519 ... alok@DESKTOP-381CHVR (your Windows key)

Secure Permissions

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Proper permissions are required for SSH to accept the keys.

Harden the SSH Configuration

Back up the original config first:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

Edit the file:

sudo vim /etc/ssh/sshd_config

Add or modify the following settings:

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication no
KbdInteractiveAuthentication no
UsePAM yes

PermitRootLogin no

AllowUsers alok

These settings enforce:

  • Key‑only authentication
  • No password logins
  • Root login disabled
  • Only user alok allowed to SSH

Apply Changes

sudo systemctl restart ssh

Verify the Hardened Setup

From Windows:

ssh alok@192.168.45.100

It should connect successfully.

On Ubuntu, confirm the password authentication setting:

sudo sshd -T | grep -i passwordauthentication

Expected output:

passwordauthentication no

Summary of SSH Status

FeatureStatus
SSH access✅ Enabled
Password login❌ Disabled
Key‑based login✅ Enabled
Root login❌ Disabled
User restriction (alok)✅ Enforced
Known host verification✅ Trusted
SSH auto‑start on boot✅ Enabled

You now have a production‑grade, DevOps‑style SSH setup on your Ubuntu VM, accessible securely from Windows. 💪

0 views
Back to Blog

Related posts

Read more »

Happy women in STEM day!! <3

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as we...