How to speed up SSH connections in GNU / Linux

linux-shell

Our SSH connections they are one of the tools most used by SysAdminThis is mainly due to its flexibility and the very good security options, but as with almost all connectivity options there are many ways to use it and some imply that the speed available is not always the best. In those cases, unfortunately, we are going to have to resort to some forms of adjustment that allow us to obtain a decent and secure connection quality, that's why we want to show 3 ways to speed up SSH connections in GNU / Linux.

Basically, we want to talk about configuration options that will allow us to overcome obstacles such as a bad connection, or the fact that we are making several connections simultaneously to the same server, in some cases even accessing graphical tools through X Forwarding, which can make the required speed high.

One of the first things we can do is force SSH connections over IPv4This protocol also admits connections to the newest IPv6, which at some point will end up being absolutely necessary but at the moment it is not, and the fact of using support for both implies that sometimes the connection can be something more slow. But we can connect to any server using SSH only through IPv4 using the parameter "-4" As follows:

# ssh -4 user@remoteserver.com

Another way to achieve this is to modify the configuration file / Etc / ssh / ssh_config, where should we look for the line "AddressFamily" and leave her with the courage "Inet", which is what implies that we will connect using IPv4.

Another configuration that will allow us to improve speed is that of disable DNS Lookup on the remote computer, and is that all this of looking for the IP of the computer and from it obtaining the host name is something that requires resources and helps to make things a little slower, for which we must also go to the file configuration of the SSH server, (/ etc / ssh / sshd_config) and leave the option of "UseDNS" with the value "No.". We can also force reuse of SSH connectionsIn other words, when establishing a new connection, an attempt will be made to reuse an already established one, something that can undoubtedly be much faster than creating a new one.

For this, we go to the file / Etc / ssh / ssh_config and add the following lines:

ControlMaster car
ControlPath - /. Ssh / sockets /% r% h-% p
ControlPersist 600

The last line (ControlPersist) will tell the SSH service to keep a connection open -but in the background- for 600 seconds after it has been closed, to reuse it in case of receiving a new connection request. If we add a line "Hostname servername" we can indicate that this configuration is only used for SSH connections to a specific computer, for which we replace servername with the appropriate name.

With these simple modifications we can achieve some improvement in the speed of SSH connections and also in the time it takes to establish them, something that will not be noticeable to us if we have a lot of bandwidth and we work on a local network, but which we will surely appreciate if we connect to several remote servers.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

2 comments, leave yours

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Michael Angel said

    Excellent information thank you very much |

  2.   Michael Angel said

    I use this command a lot, thank you very much