I am using the internet server of university and trying to log in to my account on system from my laptop, using ssh -X username@server. It says connection timed out. when i tried from another system i was able to log in. i use system for pretty basic work and dont know much about the internal coding and all... From some of he pages online i think the problem is firewall or something similar. I have checked the status for open ssh server which is shown as active. Kindly guide me through how to solve this problem.

  • Ubuntu 18.04. and connecting from with in university. and using the address provided by the officilas... the same address works if i am doing it through another system that has the same version of ubuntu. Apr 11, 2019 at 17:07
  • i havent done anything to have firewall. "ufw" shows an active status, if thats related? Apr 11, 2019 at 17:15

2 Answers 2


Install ufw It will handle the firewall.

This guide will help you go through the basics of firewalls.


Run these commands on the ssh-server machine

sudo apt-get install ufw
sudo ufw allow ssh
sudo ufw enable
sudo ufw status

These will get you through.

Let me know what happened.

  • ufw is already working. and status is also active. Apr 11, 2019 at 17:09
  • what does the status show? when you press sudo ufw status is it something like 22/tcp ALLOW ANYWHERE
    – Godfather
    Apr 11, 2019 at 17:13
  • That it is active. Apr 11, 2019 at 17:15
  • I can understand it's active but does it say that port 22 is allowed when you ask for the status?
    – Godfather
    Apr 11, 2019 at 17:16
  • yes it does. port 22 allowed anywhere. Apr 11, 2019 at 17:17

I believe your problem is with your ssh configuration, nothing to do with firewall for outgoing SSH session. See your /etc/ssh/ssh_config file and make sure you enable both the following:

ForwardX11 yes
ForwardX11Trusted yes

For some situation, you might have to turn off trusted mode for things to work (all depends on the SSH setup in your university.

ForwardX11Trusted no

Hope this helps.


In cases where you can't edit the configuration in /etc/ssh/ssh_config, copy the file to your home directory and modify it there.

mkdir $HOME/.ssh
cp /etc/ssh/ssh_config $HOME/.ssh/config

Modify ~/.ssh/config to enable X11 forwarding.

  • Thank you for your help. i think that is actually the problem, "ForwardX11 no" i found this in the file you mentioned, but it is not allowing for the editing. what i mean is i cant save it after editting. can you kindly guide me about that... Apr 12, 2019 at 12:21
  • See if you can make a copy of the configuration file to your home directory as my.config make the modification there and then launch it with ssh -X -F my.config username@server Apr 12, 2019 at 18:46
  • I have updated the answer on how to have a user specific configuration. Apr 12, 2019 at 19:45
  • I tried the both methods. "~/.ssh/config" says permission denied and ssh -X -F my.config username@server is still connection timed out. Thank you for your time and kind help. i think i might be doing it the wrong way. Apr 13, 2019 at 4:01
  • Perhaps you can include -vvv when you try to make the ssh connection. Add the debug output to your question. I'm curious to see what other things causing the timeout. Apr 13, 2019 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .