7 Tips to Speed Up SSH Connections on Linux, Windows, and Mac

Are you experiencing slow performance or connection latency when connecting to a remote server with an SSH connection?

SSH connection is widely used by system administrators to maintain remote Linux servers. But, the SSH connection often suffers from slow response times, delay, or lag when executing remote commands or transferring data between the remote server and the Client operating system. Various reasons, including network congestion, server load, or client configuration, can cause this issue. You may need to optimize the configuration and tweak some settings to improve performance.

In this blog post, I will discuss seven tips and configure SSH settings to make SSH connections faster.

1. Use a High-quality Internet Connection

The most common reason for a slower SSH connection is the low-quality internet connection of the Client Computer. A high-quality internet connection with low latency can significantly improve the SSH connection. To ensure your internet connection is not the bottleneck for slow performance you can follow these steps.

Check Your Internet Connection

Before making changes to the SSH configuration, ensure your internet connection speed is not the bottleneck. You can check your internet connection with free tools like Speedtest.net or Fast.com. If you find your internet connection is slow, then consider upgrading your internet connection.

Use a Wired Connection

If you are using Wi-Fi to establish SSH connection, you can switch to a wired connection for a more stable connection. Wi-Fi signals can easily suffer from interference from other devices and are prone to obstacles. If you are far from the router, this can significantly reduce the connection Quality.

Limit Other Network Usage

When using SSH connection, try avoiding bandwidth intensive applications such as video streaming and downloading, which can slow down your ssh connection hence increasing lag in SSH connection.

2. Reuse SSH Connection For Faster Connection

Reusing SSH Connection allows you to establish SSH connection and reuse it for a later rather than establishing SSH connection each time. Reusing SSH connection improves the speed up of your SSH Connection as it eliminates the overhead of establishing a new SSH connection each time.

Reuse SSH Connection In Mac/Linux

Usually, when connecting to the remote server, you use

ssh -i authenticationkey.pem [email protected]

You use this command every time you make SSH connection, but you can make a configuration file to automate this process easier. To reuse an SSH connection, you need to create SSH configuration file. Then, when you make SSH connection, Openssh tends to use the configuration file to make the connection.

Enter the following command in the terminal to create a config file

nano ~/.ssh/config

Then enter these settings into the configuration file

Host Linovox
        Hostname 172.177.120.129
        User ashiqur
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/privatekey.pem
  • Host Linovox: Replaces Linovox with your Host. You can choose any name you want.
  • Hostname: Change it with the Public IP address or domain name of the server.
  • User: Change User with the login user name for SSH connection. For example, user@example.com

Note: If you use an SSH key pair to authenticate the SSH connection, use the following two lines; otherwise, remove the lines.

  • PreferredAuthentications publickey It tells SSH to authenticate through the public key/private key.
  • Specify your private key location to IdentityFile

Save the configuration file and exit the editor. You can use multiple Hosts as you want. Then you can use the following command to make SSH connection.

ssh Linovox

Creating an SSH config file simplifies the SSH connection.

Reuse SSH Connection in Windows

PuTTY is a free SSH client for Windows, providing many features to reuse the ssh connection. To reuse the SSH connection in Windows, first download PuTTY. Then open PuTTY, and you can see an interface like this.

Enter Host name in putty

Enter your Hostname or IP address and click save. Then open Data in the connection tab and enter your login user name.

auto username in putty

If you use Public and private keys for authentication, you will need to use the next steps, or if you use password for authentication, skip this step.

To set private key authentication for PuTTY expand SSH and open Auth. In Auth, browse and select the private key file if you have one.

load private key on putty

After these following configurations, go to session and save the configuration.

save session on putty

The next time you need to connect SSH, open PuTTY and Load the configuration file. The reuse of SSH connection makes establishing a connection easier. To reuse the SSH connection next time, just load the saved session and connect.

Pro Tips: If you are a Windows user, you can utilize SSH in PowerShell and proceed with the remaining steps in the tutorial.

3. Use a Newer SSH version

Older SSH versions can result in slow SSH connection and lead to vulnerability and security risks. Upgrading SSH version can improve the connection. If you are using an older version of SSH you can upgrade using the following command on Debian or Ubuntu.

sudo apt-get update
sudo apt-get install openssh-server

If you are using macOS SSH will be updated with your system upgrade, so you don’t have to worry about it.

4. Adjust SSH settings

You can also tweak SSH configuration file for a faster SSH connection. The SSH configuration affects the security and stability of SSH Connection. So before optimizing the SSH configuration file, it is a good idea to back up the existing one. To create a backup, enter the following command

sudo cp /etc/ssh/ssh_config /etc/ssh/ssh_config.bak

This command will create a backup of the existing SSH configuration to /etc/ssh/ssh_config.bak file.

If you got into trouble during this tutorial, you could restore SSH configuration with a backup file using the command.

sudo rm /etc/ssh/ssh_config
sudo cp /etc/ssh/ssh_config.bak /etc/ssh/ssh_config

Use DNS

This configuration applies to the remote servers only. So connect your server through SSH and edit SSH configuration file

sudo nano /etc/ssh/sshd_config

and uncomment the following line

	UseDNS no

This configuration may lead to more traffic and resource consumption and cause delays in the authentication process. So use this configuration when it makes sense.

Use DNS in SSH configuration for faster ssh connection

Use Compression

Using compression is another way to speed up SSH connection. Compression can reduce the remote server and client data transfer, improving the SSH connection speed. To enable compression add the following line to your configuration file.

	Compression yes

But this can slow down your connection if the CPU lacks adequate power. You can use compression when the CPU has enough power. To do this, add the following line to your config setting.

	Compression delayed

This line will delay the compression if the CPU lacks enough power to avoid your server’s unwanted slowdown.

5. Use Multiplexing

SSH multiplexing allows you to reuse a single SSH connection for multiple sessions, which can reduce the overhead of establishing and tearing down SSH connections. To enable multiplexing, open your SSH config file.

sudo nano /etc/ssh/ssh_config

Add the following lines to the configuration

  ControlMaster auto
  ControlPath ~/.ssh/control:%h:%p:%r
  ControlPersist 10m
  • ControlPersist Specifies the time when the control socket remains open.

Using Multiplexing can cause a security issue if your control socket is compromised. So use this option at your own risk.

SSH multiplexing

6. Use a Faster Encryption Algorithm

The performance of SSH connection depends on the encryption method used. By default, SSH connection uses AES-128 algorithm which is fast enough but lacks security features. So you may choose to faster encryption method with added security features such as AES-256 or ChaCha20. To use these encryption algorithms. Add the following line to your SSH client configuration file (~/.ssh/config):

Ciphers [email protected],[email protected],aes256-ctr,aes256-cbc

This line specifies the list of algorithms to use in the order of preference. The first two algorithms are faster than the last, so we listed them first.

7. Use a Faster SSH Client

The connection speed greatly depends on the SSH clients used. The choice of SSH client depends on the operating system used. If you are using Windows, you can use WSL( Windows Subsystem for Linux) or PuTTY, a popular SSH client for Windows Operating System.

Linux uses OpenSSH client by default which is fast enough, but you can check other alternatives such as MobaXtermBitvise SSH Client, or Tera Term as your need.

Conclusion

Slow response times or delays in SSH connection hamper the workflow of the system administrator. Several optimization options for faster SSH connection can improve overall speed and security. By following this tutorial, you can speed up your SSH Connection. Don’t forget to share your thoughts with us in the comment section.

Share your love

Newsletter Updates

Stay updated with our latest guides and tutorials about Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *