I'm trying to ssh to my Server. The SSH service is active when i check it with
sudo service ssh status
Also when i do netstat -nat | grep 22 i get
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 xx.xx.xx.xx:22 xx.xx.xx.xx:54197 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
I'm running following command on my Terminal:
ssh root@xx.xx.xx.xx
and i get following error
ssh: connect to host xx.xx.xx.xx port 22: Connection timed out
I also limited the access to my server via iptables. When i enter iptables -L i get following lines:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- x.x.x.x anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT all -- anywhere x.x.x.x
ACCEPT tcp -- anywhere anywhere tcp spt:ssh
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
I have absolutly no clue how i can fix this issue. Can anyone help me?
Kind regards, Kevin
ssh root@xx.xx.xx.xx
from the local machine or from remote machine? Maybe there is a firewall and you need to open port 22 in it. – pa4080 Jul 20 '17 at 07:53ssh root@localhost
? – Ziazis Jul 20 '17 at 07:53I also have to say i settup up some iptables so that the server is only accessible from my IP-Adress
– Stark Toni Jul 20 '17 at 08:00sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
or with UFW:sudo ufw limit 22
. The limit rule is better, and if you want to implement it through iptables directly check this answer. – pa4080 Jul 20 '17 at 08:07I runned those command on those answer. But still no connection from my local pc possible ...
– Stark Toni Jul 20 '17 at 08:14sudo iptables -I INPUT -p tcp --dport 22 -j ACCEPT
where-I
will insert the rule at the top of the chain, unlike-A
which appends rules to the end of the chain. – pa4080 Jul 20 '17 at 08:21/etc/ssh/sshd_config
? – pa4080 Jul 20 '17 at 08:25Yeah in /etc/ssh/sshd_config the port is configured 22
– Stark Toni Jul 20 '17 at 08:28iptables -F
) to clarify if this is the problem. Also I would carefully reading this and this topic about iptables configuration. Btw UFW is nice iptables manager. – pa4080 Jul 20 '17 at 08:38