Unlocking SSH Superpowers: 5 Essential Tips for Linux Servers 🚀

Shreyas SShreyas S
4 min read

When you're managing Linux virtual machines or bare-metal servers, SSH (Secure Shell) is your best friend — but are you using it to its full potential?

Beyond simple ssh user@server, mastering a few SSH tricks can save time, enhance security, and improve reliability when working remotely.
Here are 5 essential tips to get you there:

1. File Editing Essentials

Once you're inside a Linux server, you'll often need to edit files — like SSH configs, firewall rules, service files, and more.

Knowing a few important text editor commands can save you from frustration:

#Navigate and open the file for editing
sudo nano /path/to/file
  • Nano is simple and beginner-friendly (Save: Ctrl + O, Exit: Ctrl + X).

  • If using vim (or vi), which you'll find on almost all servers:

    • Press i to start inserting text.

    • Press Esc to exit insert mode.

    • To save and exit, type :wq and hit Enter.

    • To force quit without saving, type :q! and hit Enter.

Always backup critical files before editing, specially while working with live servers:

#For backing up important files
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

2. File transfer with ‘scp’: Securely Move Files Between Machines

You’ll often need to move files between your local machine and the server. It’ll involve both uploading and downloading.

#Upload a file
scp -i /path/to/key myfile.txt user@server_ip:/path/to/destination/

#Download a file
scp -i /path/to/key user@server_ip:/path/to/file.txt ~/Downloads/

FTP should be avoided primarily due to its lack of encryption and weak authentication, making it a highly insecure protocol. This means sensitive data like usernames and passwords are transmitted in plain text, making them vulnerable to interception and potential theft. Additionally, FTP lacks integrity checks and authorization mechanisms, further increasing the risk of data breaches and unauthorized access.

SCP, on the other hand, leverages SSH for secure file transfers, encrypting data and providing robust authentication, making it a much more secure and reliable option.

Moving files across two remote server :

scp -i key.pem user1@server1:/path/file.txt user2@server2:/path/

3. Use tmux to Keep Processes Running: Never Lose Your Session Again

Ever started a long process (like yum update) and lost connection? By installing and using tmux, even if SSH dies, the session stays alive. This enable users to reconnect to the session again.

To detach from a session, hit Ctrl+b, d. The session disappears and you’ll be back at the standard single shell.

#Install tmux
sudo dnf -y install tmux

#Reconnect later with:
tmux attach

#See available sessions 
tmux list-sessions

4. “Select-All” Inside Nano or Vim: Efficiently Manage File Content

When editing files via SSH, sometimes you need to copy everything, delete everything, or replace whole content.
Here’s how to do it easily:

  • In nano:

    1. Move the cursor to the start of the file (Ctrl + _, then type 1 to jump to line 1).

    2. Press Ctrl + Shift + ^ to start selecting text.

    3. Use arrow keys (↓) to select until the end.

    4. Then:

      • Cut selected text: Ctrl + K

      • Copy selected text: Alt + 6

      • Paste anywhere: Ctrl + U

  • In vim:

    1. Press gg (go to the very top of the file).

    2. Then press V (capital V) to start Visual Line mode.

    3. Press G to select till the end of the file.

    4. Now:

      • Delete selected: Press d

      • Copy selected: Press y

      • Paste somewhere: Press p

➔ This trick saves you from deleting letter-by-letter or struggling to copy huge files manually!

5. Save Your SSH Connections with a Config File: Simplify Your Server Access

Avoid retyping long commands! Create a ~/.ssh/config file:

Host myserver
    HostName 192.168.1.100
    User myusername
    IdentityFile ~/.ssh/my_private_key

#Now the server can be directly accessed by using
ssh myserver

This avoids typing in the whole command for initializing connection. Nice little trick which comes handy when you’re dealing with a bunch of servers and can’t afford to remember/identify all the IPs.

BONUS: Supercharge Your Vim Skills with These Quick Tips

If you want to get even faster and more comfortable while editing with vim, here are a few simple but game-changing tricks:

  • Show line numbers (helps when following error logs or editing configs):

      :set number
    

    You’ll now see line numbers on the left —
    making it super easy to find where settings are or follow errors that say "error at line 24".

  • Quickly search for any word or setting inside the file:

      /pattern
    

    Example: typing /Port inside sshd_config jumps you to the SSH port settings. (You can press n to move to the next match.)

  • Jump directly to a specific line (super useful when error messages mention a line number):

      :45
    

    (jumps to line 45)

  • Undo your last change (if you made a mistake):

      u
    
  • Redo something you just undid:

      Ctrl + r
    

These small tricks make vim feel less scary and way more powerful — especially when you're managing production servers!

In conclusion, mastering these SSH tips can significantly enhance your efficiency, security, and reliability when managing Linux servers. Apply these strategies to streamline your workflow and optimize server management.

0
Subscribe to my newsletter

Read articles from Shreyas S directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shreyas S
Shreyas S