3

I have a server where I just use openssh, openvpn and rabbitmq (which requires a lot of erlang dependencies).

Every time I reboot my server I can't access to it anymore getting

Port 22: Connection Refused

And I have to install everything from scratch.

What should I check to avoid this problem??

AAlvz
  • 365
  • 4
  • 7
  • 16
  • 1
    possible duplicate of [What causes the 'Connection Refused' message?](http://serverfault.com/questions/725262/what-causes-the-connection-refused-message) – user9517 Sep 28 '15 at 18:28

3 Answers3

4

To view your firewall settings in a terminal perform the following: -

sudo iptables -L -n

you looking for somehting ike this

# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
DROP       all  --  anywhere             anywhere

if no port ssh (22) rule is set then try:

sudo iptables -I INPUT -p tcp -m tcp --dport 22 -j ACCEPT

save current iptables firewall rules to a file called /root/dsl.fw, type:

# iptables-save > /root/dsl.fw

To restore iptables rules, enter:

iptables-restore < /root/dsl.fw

To restore rules automatically upon Linux system reboot add following command to your /etc/rc.local file, enter:

# vi /etc/rc.local

Append the line:

/sbin/iptables-restore < /root/dsl.fw

To check what init services are running and at what run level try this in a terminal

ls /etc/rc*.d

if sshd is not listed do then enter this in your terminal:

update-rc.d ssh enable
nickleefly
  • 103
  • 3
AngryWombat
  • 499
  • 3
  • 6
3

Port 22: Connection Refused

This message indicates that a firewall is actively blocking your connection attempt or alternatively that sshd is not listening on that port.

Verify that:

  1. The iptables rules applied on boot allow traffic on port 22
  2. sshd is set to start on boot
EEAA
  • 108,414
  • 18
  • 172
  • 242
-2

Just try (as root)

sudo apt-get install ssh

i havn't ssh server in standard ubuntu desktop installation

blackmoon
  • 1
  • 1
  • 1
    While this might actually get one past the problem by reinstalling and restarting ssh, it's hardly a solution. One would be better served trying to find out *why* this is happening and prevent it from happening again. –  Nov 06 '13 at 18:06