Setting up a fast SSH connection on Linux

Setting up a fast SSH connection on Linux

In some cases you may see a slow response from the Linux system when trying to connect via SSH. This can happen either during the login phase or after entering the password. There are several solutions to fix the situation.

1. UseDNS

Mainly, SSH connection is slow because of unsuccessful attempts to resolve names in the DNS system.



To reduce login waiting time, open the following file for editing:

vi /etc/ssh/sshd_config

Find the line:



#UseDNS yes

And we bring it to the following form:

UseDNS no

* in the specific example, we removed the comment and replaced yes with no than disabled DNS name resolution every time we tried to connect. If our Linux server is not configured with DNS (or is configured incorrectly) this will solve the problem of a slow SSH.

** if there is no such line it is necessary to add it.

For the changes to take effect we restart the service:

systemctl restart sshd || systemctl restart ssh

* or service sshd restart || service ssh restart

2. GSSAPIAuthentication

GSSAPI provides an API for various authentication options in the system. However, in most cases the standard PAM method is used. Disabling GSSAPI can significantly speed up SSH login.

Open sshd_config:

vi /etc/ssh/sshd_config

And give two lines to the following view:

GSSAPIAuthentication no

GSSAPICleanupCredentials yes

* in this example we disabled authentication using GSS-API (common program interface for security services). It can be used, for example, for communication with Kerberos. However, the PAM method is most often used and there is no need for GSSAPIAuthentication.

We restart:

systemctl restart sshd || systemctl restart ssh

3. motd

Under Linux Ubuntu, the welcome file /etc/motd performs various tasks when logged in, such as checking for updates which can slow down the login. In this case the slowdown will be at the stage after entering the password.

To disable the greeting module, open two files for editing:

vi /etc/pam.d/login

vi /etc/pam.d/sshd

And comment on all the lines that contain pam_motd.so.

Restart sshd:

systemctl restart sshd || systemctl restart ssh

We hope that this article was useful for you.



WARNING! All links in the articles may lead to malicious sites or contain viruses. Follow them at your own risk. Those who purposely visit the article know what they are doing. Do not click on everything thoughtlessly.


11 Views

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments


Do NOT follow this link or you will be banned from the site!
0
Would love your thoughts, please comment.x
()
x

Spelling error report

The following text will be sent to our editors: