Solve Slow Access To Gitlab via ssh
300 Words | Read in about 2 Min | View times
I’ve deployed a custom gitlab server for my team. I found that it’s weired that when clone, pull, push or fetch codes from the gitlab server via SSH, it performs slow response times for each access. But it works perfectly via HTTPS.
After seaching sort of posts, it’s pointed that the SSH service of gitlab server enables UseDNS
feature by default, which makes it slow to access via SSH.
While it is possible to run a GitLab instance using only IP addresses, it is often beneficial to use DNS as it is easier for users and is required for HTTPS. Depending on the features you want to take advantage of, multiple DNS entries may be necessary. Any of these DNS entries should be of type A, AAAA, or CNAME. This depends on the underlying architecture of the instance you are using.
When enable this feature, gitlab server will first perform DNS PTR reverse query according to the client’s IP address to obtain the client’s host name. Then perform DNS forward query by the host name, the IP address obtained is compared with the client’s IP address to check whether it’s consistant to prevent client deception.
Workaround
- Login gitlab server via SSH as root.
- Edit the file
/etc/ssh/sshd_config
. - Modify “#UseDNS yes” as “UseDNS no”.
- Save the config and restart the sshd service:
1$ sudo service sshd restart
After doing this, the slow access to gitlab server is gone!