What is SSH!π
SSH (Secure Shell) is a secure network protocol that enables users to access & manage remote machines securely over an encrypted connection. It provides a safe & encrypted way to execute commands, transfer files, & perform various tasks on remote servers. #SSH
SSH (Secure Shell) is a secure network protocol that enables users to access & manage remote machines securely over an encrypted connection. It provides a safe & encrypted way to execute commands, transfer files, & perform various tasks on remote servers. #SSH
1/ πTo connect to a remote machine, use:
ssh username@remote_host
Replace "username" with your account & "remote_host" with the server's IP/hostname. #SecureConnections #RemoteAccess
ssh username@remote_host
Replace "username" with your account & "remote_host" with the server's IP/hostname. #SecureConnections #RemoteAccess
2/ποΈ Did you know? You can use SSH keys for authentication, avoiding passwords. Generate your key pair with:
ssh-keygen -t rsa
Then copy your public key to the remote server's ~/.ssh/authorized_keys file.
#KeyAuthentication #SecurityMatters
ssh-keygen -t rsa
Then copy your public key to the remote server's ~/.ssh/authorized_keys file.
#KeyAuthentication #SecurityMatters
3/π To execute commands on the remote server, simply:
ssh username@remote_host command
It'll run "command" on the server & show the output locally. Handy, right?
#RemoteCommands #SysAdminLife
ssh username@remote_host command
It'll run "command" on the server & show the output locally. Handy, right?
#RemoteCommands #SysAdminLife
4/ π Copying files between local & remote machines? Rely on SCP (SSH Copy):
scp /path/to/local_file username@remote_host:/path/to/destination
Securely transfer files without fuss!
#FileTransfer #SSH
scp /path/to/local_file username@remote_host:/path/to/destination
Securely transfer files without fuss!
#FileTransfer #SSH
5/π Need to forward ports for secure access to services? Use SSH port forwarding:
ssh -L local_port:destination_host:remote_port username@jump_host
Now access destination_host:remote_port via localhost:local_port.
#PortForwarding #NetworkingTricks
ssh -L local_port:destination_host:remote_port username@jump_host
Now access destination_host:remote_port via localhost:local_port.
#PortForwarding #NetworkingTricks
6/β²οΈ Running a long task? Prevent disconnection by keeping SSH session alive:
ssh -o ServerAliveInterval=60 username@remote_host
SSH will send a "keep-alive" signal every 60 seconds. No more annoying timeouts!
#StayConnected #ProductivityHacks
ssh -o ServerAliveInterval=60 username@remote_host
SSH will send a "keep-alive" signal every 60 seconds. No more annoying timeouts!
#StayConnected #ProductivityHacks
7/πͺ Change the default SSH port for added security:
sudo nano /etc/ssh/sshd_config
Modify "Port 22" to a custom port, then restart SSH service. Impenetrable! π
#SecurityFirst #CustomPort
sudo nano /etc/ssh/sshd_config
Modify "Port 22" to a custom port, then restart SSH service. Impenetrable! π
#SecurityFirst #CustomPort
8/ π§ Enable X11 forwarding to run GUI applications remotely:
ssh -X username@remote_host
Now, when you run GUI apps, they'll display on your local machine!
#GUIoverSSH #RemoteApps
ssh -X username@remote_host
Now, when you run GUI apps, they'll display on your local machine!
#GUIoverSSH #RemoteApps
9/ ποΈ To securely store passwords, use SSH-agent:
eval "$(ssh-agent)" ssh-add /path/to/private_key
No more entering passwords repeatedly! π
#SSHAgent #PasswordSecurity
eval "$(ssh-agent)" ssh-add /path/to/private_key
No more entering passwords repeatedly! π
#SSHAgent #PasswordSecurity
10/ π Disallow root login via SSH to bolster security:
sudo nano /etc/ssh/sshd_config
Set "PermitRootLogin" to "no", then reload SSH. Elevate privileges smartly!
#RootLoginDenied #SecurityTips
sudo nano /etc/ssh/sshd_config
Set "PermitRootLogin" to "no", then reload SSH. Elevate privileges smartly!
#RootLoginDenied #SecurityTips
11/ πͺ Limit user access with SSH chroot:
sudo nano /etc/ssh/sshd_config
Use "ChrootDirectory" to restrict users to their home directories. Isolate & control!
#UserIsolation #AccessControl
sudo nano /etc/ssh/sshd_config
Use "ChrootDirectory" to restrict users to their home directories. Isolate & control!
#UserIsolation #AccessControl
12/ π Search remote files like a pro with "grep" over SSH:
ssh username@remote_host "grep -r 'search_term' /path/to/directory"
Search for 'search_term' in files located at '/path/to/directory' on the remote host.
#RemoteSearch #SysAdminTricks
ssh username@remote_host "grep -r 'search_term' /path/to/directory"
Search for 'search_term' in files located at '/path/to/directory' on the remote host.
#RemoteSearch #SysAdminTricks
13/ π Edit files on the fly using "sed" over SSH:
ssh username@remote_host "sed -i 's/old_text/new_text/g' /path/to/file"
Replace 'old_text' with 'new_text' in the specified file. Changes applied remotely!
#SSHsed #RemoteEditing
ssh username@remote_host "sed -i 's/old_text/new_text/g' /path/to/file"
Replace 'old_text' with 'new_text' in the specified file. Changes applied remotely!
#SSHsed #RemoteEditing
14/ π Monitor resource usage with "top" remotely:
ssh username@remote_host "top"
Get real-time insights into processes, CPU, and memory usage on the remote machine.
#RemoteMonitoring #SysAdminLife
ssh username@remote_host "top"
Get real-time insights into processes, CPU, and memory usage on the remote machine.
#RemoteMonitoring #SysAdminLife
15/ π Synchronize local and remote directories using "rsync" over SSH:
rsync -avz -e "ssh" /path/to/local_dir username@remote_host:/path/to/destination
Efficiently transfer files between local and remote locations.
#RSync #DataSync
rsync -avz -e "ssh" /path/to/local_dir username@remote_host:/path/to/destination
Efficiently transfer files between local and remote locations.
#RSync #DataSync
1/ π Enable debug mode to troubleshoot SSH connection issues:
ssh -v username@remote_host
Verbose mode displays detailed connection process. Unravel the mysteries!
#SSHDebugMode #Troubleshooting
ssh -v username@remote_host
Verbose mode displays detailed connection process. Unravel the mysteries!
#SSHDebugMode #Troubleshooting
2/π Authenticate with PEM file (private key) instead of passwords:
ssh -i /path/to/key.pem username@remote_host
Boost security & login with your PEM file. No more passwords! π
#PEMfile #SecureAuthentication
ssh -i /path/to/key.pem username@remote_host
Boost security & login with your PEM file. No more passwords! π
#PEMfile #SecureAuthentication
3/ π Copy files using PEM file with SCP:
scp -i /path/to/key.pem /path/to/local_file username@remote_host:/path/to/destination
Combine security & file transfer in one go! π
#SCPPemFile #SecureCopy
scp -i /path/to/key.pem /path/to/local_file username@remote_host:/path/to/destination
Combine security & file transfer in one go! π
#SCPPemFile #SecureCopy
4/ π‘οΈ Use PEM file with Rsync for secure synchronization:
rsync -avz -e "ssh -i /path/to/key.pem" /path/to/local_dir username@remote_host:/path/to/destination
Safeguard data while syncing directories. π
#RSyncPEM #SecureDataSync
rsync -avz -e "ssh -i /path/to/key.pem" /path/to/local_dir username@remote_host:/path/to/destination
Safeguard data while syncing directories. π
#RSyncPEM #SecureDataSync
6/ π¦π»SSHFS: Mount remote directories over SSH.
Install 'sshfs' & mount like:
π» sshfs user@example[dot]com:/remote/path /local/mount/point
Install 'sshfs' & mount like:
π» sshfs user@example[dot]com:/remote/path /local/mount/point
7/ π¦π»SSHKnownHosts: Manage known hosts to prevent man-in-the-middle attacks.
π»nano ~/.ssh/known_hosts
π»nano ~/.ssh/known_hosts
Go forth and master these advanced SSH commands! πͺ Happy remote management!
#SSHAdvanced #SysAdminTools
(Note: Always exercise caution when executing commands that modify or transfer data remotely.)
#SSHAdvanced #SysAdminTools
(Note: Always exercise caution when executing commands that modify or transfer data remotely.)
Retweet the thread if you find it useful. Thanks!
Loading suggestions...