SSH basics for Indian VPS users: connecting and navigating your server
10 min read · 05-Mar-2025
villagehosting.in team
5 March 2025
SSH (Secure Shell) is the terminal you use to control a Linux VPS. Every server management task — installing software, editing config files, checking logs, deploying code — happens here. Here is everything you need to get started.
Use SSH keys from day one
Password-based SSH is convenient but vulnerable to brute-force attacks — bots attempt thousands of combinations per minute on port 22. Set up SSH key authentication on your first day with a new VPS, before doing anything else. A 5-minute setup eliminates the most common VPS compromise vector entirely.
What SSH is
SSH gives you a command-line terminal on a remote server. It is like sitting in front of the server — but over an encrypted connection from your laptop.
The SSH connection uses port 22 by default and authenticates with either:
- A password (simple but less secure)
- An SSH key pair (recommended)
Connecting from Windows
Option A: Windows Terminal / PowerShell (Windows 10+) Windows now includes a built-in SSH client. Open Windows Terminal or PowerShell:
ssh username@your-server-ip
Example:
ssh root@103.56.89.234
Type yes when asked about the host fingerprint. Enter your password.
Option B: PuTTY (traditional, still widely used) Download PuTTY from putty.org. Enter your server IP in "Host Name", keep port 22, click Open.
Connecting from Mac or Linux
Open Terminal and run:
ssh username@your-server-ip
Setting up SSH key authentication (more secure than passwords)
SSH keys eliminate the need to type a password and are much more secure.
Step 1: Generate a key pair on your local machine
On Mac/Linux/Windows Terminal:
ssh-keygen -t ed25519 -C "your-email@example.com"
Press Enter for the default location (~/.ssh/id_ed25519). Set a passphrase if you want extra security.
This creates two files:
~/.ssh/id_ed25519— your private key (never share this)~/.ssh/id_ed25519.pub— your public key (safe to share)
Step 2: Copy the public key to the server
Mac/Linux:
ssh-copy-id username@your-server-ip
Windows (manual):
# Get the public key content
cat ~/.ssh/id_ed25519.pub
Log into the server with password, then:
mkdir -p ~/.ssh
echo "paste_your_public_key_here" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
Step 3: Test key-based login
ssh username@your-server-ip
If it connects without asking for a password, key authentication is working.
Essential Linux commands
Once connected, you are at a command-line prompt. The most important commands:
Navigation:
pwd # print working directory (where am I?)
ls # list files in current directory
ls -la # list files including hidden files, with details
cd /path/to/dir # change directory
cd .. # go up one directory
cd ~ # go to your home directory
File operations:
cat filename.txt # view file contents
nano filename.txt # edit a file (simpler editor)
vim filename.txt # edit a file (more powerful editor)
cp source dest # copy file
mv source dest # move or rename file
rm filename # delete file (permanent, no trash!)
rm -rf directoryname # delete directory and all contents (dangerous!)
mkdir dirname # create directory
Process management:
ps aux # list all running processes
top # interactive process viewer (press q to quit)
htop # better interactive process viewer (install with apt)
kill PID # send SIGTERM to process ID
kill -9 PID # force-kill process
Package management (Ubuntu/Debian):
sudo apt update # update package list
sudo apt upgrade # upgrade installed packages
sudo apt install nginx # install a package
sudo apt remove nginx # remove a package
Services:
sudo systemctl status nginx # check service status
sudo systemctl start nginx # start service
sudo systemctl stop nginx # stop service
sudo systemctl restart nginx # restart service
sudo systemctl enable nginx # start automatically on reboot
Disk and memory:
df -h # disk usage (human-readable)
du -sh /var/www # size of a specific directory
free -h # memory usage
Viewing logs:
tail -f /var/log/nginx/error.log # stream log file (Ctrl+C to stop)
tail -n 100 /var/log/syslog # last 100 lines of syslog
grep "error" /var/log/nginx/error.log # search log for "error"
Creating and managing users
Create a non-root user (always do this on a fresh VPS):
adduser yourname
usermod -aG sudo yourname # give sudo access
Switch user:
su - yourname
Run a command as root:
sudo command
Transferring files via SCP
SCP (Secure Copy) transfers files over SSH.
Download file from server to local:
scp username@your-server-ip:/path/to/file ~/local/destination/
Upload file from local to server:
scp ~/localfile.zip username@your-server-ip:/path/on/server/
Upload entire folder:
scp -r ~/local-folder username@your-server-ip:/path/on/server/
For large or ongoing transfers, rsync is more efficient:
rsync -avz ~/local-folder/ username@your-server-ip:/path/on/server/
Keeping your SSH session alive
Long SSH sessions disconnect if idle. Fix on the server side:
Edit /etc/ssh/sshd_config:
ClientAliveInterval 60
ClientAliveCountMax 10
Restart SSH: sudo systemctl restart sshd
Or on the client side, add to ~/.ssh/config:
Host *
ServerAliveInterval 60
Securing SSH
Change the default port (reduces bot scanning):
Edit /etc/ssh/sshd_config:
Port 2222 # or any port above 1024
Update UFW: sudo ufw allow 2222/tcp (before restarting SSH)
Connect with: ssh -p 2222 username@your-server-ip
Disable root login:
PermitRootLogin no
Always create a non-root user with sudo access first.
Disable password authentication (use keys only):
PasswordAuthentication no
Only do this after confirming key-based login works. Otherwise you will lock yourself out.
After any sshd_config changes:
sudo systemctl restart sshd
Common SSH errors
"Connection refused": SSH is not running, or you are connecting to the wrong port. Check with your hosting provider.
"Permission denied (publickey)": Key authentication failed. Verify the public key is in ~/.ssh/authorized_keys on the server, and that permissions are correct (600 for the file, 700 for the .ssh directory).
"Host key verification failed": The server's fingerprint changed (happens after a server reinstall). Remove the old key: ssh-keygen -R your-server-ip
Disconnects after 5–10 minutes idle: Set ServerAliveInterval 60 in your SSH client config.