If you’ve ever used a remote Linux server, then chances are that you’ve used SSH (Secure Shell). It’s a mainstay for remote server management, but it’s far more versatile than just providing secure access. With the right know-how, you can make SSH even better and make it handle everything from tunneling web traffic to optimizing connection speed. Here’s a rundown of the most useful SSH features you may not know about, each designed to make remote work smoother and more efficient.
5 SSH multiplexing to speed up your connections
Reusing the connection
SSH multiplexing is all about creating a single “master” connection to a server and then reusing that connection for additional sessions. Instead of opening a new SSH session every time, multiplexing allows you to set up one main connection and reuse it, which is faster and more efficient. By establishing one main connection, additional SSH sessions to the same host are nearly instant. Just configure your ~/.ssh/config file like the following:
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 10m
- ControlMaster auto: Enables multiplexing and designates the first session as the “master.”
- ControlPath ~/.ssh/sockets/%r@%h-%p: Sets the path for the socket file, which is the shared connection used by additional SSH sessions. This file path must be unique for each server, which %r (user), %h (host), and %p (port) help accomplish.
- ControlPersist 10m: Keeps the master session open even after you close all SSH windows, remaining available for 10 minutes in case you reopen an SSH session during that time.
Now, whether you’re uploading files or managing multiple terminals, the connection will be faster.
4 Use SSH for tunnelling
Route your traffic through a remote server
Using SSH to set up a SOCKS proxy is a powerful and quick way to route your internet traffic securely through a remote server. Essentially, this method allows you to tunnel your browsing traffic through an encrypted connection to your SSH server, functioning somewhat like a personal VPN.
To use your server as a tunnel for your network, you can use ssh -D 8080 user@host to connect and route web traffic through the server. It will allow you to use it as a makeshift VPN, and means you can access services locally running on that server, too.
3 Compress your SSH stream
Use less data when using SSH
SSH compression can be a big help when you’re working over a slow or limited network. With SSH compression enabled, the data sent between your device and the server is compressed on the fly, using less bandwidth and potentially speeding up your connection. It uses additional resources and can slow things down in some instances, especially if you have a faster internet connection.
To enable it, simply add -C to your ssh command, where the ssh command is ssh -C user@host. You can also set it locally on the client-side by adding “Compression yes” to your ssh config.
2 Transfer files with SFTP
Easily upload or download files
If you need to move files between your local machine and a remote server, SSH offers a secure, built-in way to do it using SFTP (Secure File Transfer Protocol). SFTP isn’t really related to FTP at all, even though it shares a similar name. To start an SFTP session, just use the command:
sftp user@host
Once connected, you can use commands like get to download files or put to upload them, all from within an SSH connection.
1 SSH key agent forwarding
Use your data locally without needing to worry about leaving credentials on the server
SSH key agent forwarding allows you to use your local SSH keys on remote servers without having to copy them. This is helpful when you need to access a third server from within a remote session but want to keep your private key secure on your local machine. Enable it with ssh -A user@host, and once logged in, any command that requires SSH key authentication will use your local key. This feature keeps your credentials safe from potential exposure on the remote server.
#SSH #features
source: https://www.xda-developers.com/ssh-features-might-not-know-about/


