localhost:22 — SSH & SFTP

Port 22 is the default port for SSH (Secure Shell) and SFTP (SSH File Transfer Protocol). SSH provides encrypted remote terminal access, while SFTP enables secure file transfers — both essential tools for developers and system administrators.

Connect via SSH: ssh user@localhost

What is SSH?

SSH (Secure Shell) is a cryptographic network protocol that provides secure encrypted communication between two computers. It's used for:

  • Remote terminal access — Run commands on remote servers
  • Secure file transfer — SFTP and SCP protocols
  • Port forwarding — Tunnel other protocols securely
  • Key-based authentication — More secure than passwords

SSH Connection Commands

# Basic SSH connection
ssh username@localhost

# Specify port (if not default 22)
ssh -p 22 username@localhost

# Use SSH key for authentication
ssh -i ~/.ssh/id_rsa username@localhost

# Enable verbose mode for debugging
ssh -v username@localhost

# Execute single command
ssh username@localhost "ls -la"

SFTP File Transfer

# Connect via SFTP
sftp username@localhost

# SFTP Commands
ls              # List remote files
lls             # List local files  
cd folder       # Change remote directory
lcd folder      # Change local directory
get file.txt    # Download file
put file.txt    # Upload file
rm file.txt     # Delete remote file
exit            # Disconnect

# SCP (single file copy)
scp file.txt user@localhost:/path/
scp user@localhost:/remote/file.txt ./

SSH Clients by Platform

PlatformBuilt-inGUI Clients
Windows 10/11OpenSSH (cmd/PowerShell)PuTTY, MobaXterm
macOSTerminalTermius, iTerm2
LinuxTerminalTerminator
SFTP GUIWinSCP, FileZilla, Cyberduck

Enable SSH Server

Windows 10/11

# Settings → Apps → Optional Features → Add OpenSSH Server

# Or via PowerShell (Admin):
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic

Ubuntu/Debian Linux

sudo apt update
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo systemctl status ssh

macOS

System Preferences → Sharing → Enable "Remote Login"

SSH Key Authentication

# Generate SSH key pair
ssh-keygen -t ed25519 -C "your_email@example.com"

# Copy public key to server
ssh-copy-id username@localhost

# Or manually add to ~/.ssh/authorized_keys

Troubleshooting

ProblemSolution
Connection refusedStart SSH service: sudo systemctl start ssh
Permission deniedCheck password or SSH key
Host key verification failedssh-keygen -R localhost
TimeoutCheck firewall allows port 22