Unlocking SSH Superpowers: 5 Essential Tips for Linux Servers đ

Table of contents
- 1. File Editing Essentials
- 2. File transfer with âscpâ: Securely Move Files Between Machines
- 3. Use tmux to Keep Processes Running: Never Lose Your Session Again
- 4. âSelect-Allâ Inside Nano or Vim: Efficiently Manage File Content
- 5. Save Your SSH Connections with a Config File: Simplify Your Server Access

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
:Move the cursor to the start of the file (
Ctrl + _
, then type1
to jump to line 1).Press
Ctrl + Shift + ^
to start selecting text.Use arrow keys (
â
) to select until the end.Then:
Cut selected text:
Ctrl + K
Copy selected text:
Alt + 6
Paste anywhere:
Ctrl + U
In
vim
:Press
gg
(go to the very top of the file).Then press
V
(capital V) to start Visual Line mode.Press
G
to select till the end of the file.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
insidesshd_config
jumps you to the SSH port settings. (You can pressn
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.
Subscribe to my newsletter
Read articles from Shreyas S directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
