Slow SSH and GVFS on Ubuntu 22.04#

Recently, after upgrading to Ubuntu 22.04, I noticed that SSH connections were very slow. It took about 10 seconds to connect to a remote server. I also noticed that the GVFS (GNOME Virtual File System) was also very slow. It took about 30 seconds to mount a folder on Sunbird in Nautilus. It turns out ssh -v might reveal the problem.

In my case it was GSSAPIAuthentication and multiple known-hosts files. I had to disable GSSAPIAuthentication and remove the extra known-hosts files.

sudo nano /etc/ssh/ssh_config

We add the following line to the file to make the settings system-wide:

Host *
    UserKnownHostsFile ~/.ssh/known_hosts
    # other directives...
    GSSAPIAuthentication no

We can do it on case-by-case basis by adding the following to the ~/.ssh/config file:

Host    sunbird
    User    s.1915438
    HostName    sunbird.swansea.ac.uk
    IdentityFile    ~/.ssh/id_rsa
    IdentitiesOnly  yes
    GSSAPIAuthentication no

Now the SSH connection is instant and GVFS is also fast.