You are not logged in.

#1 2021-03-26 06:31:35

Anarchish
Member
Registered: 2021-03-22
Posts: 5

ssh: connect to host xx.xx.xx port 22: Operation timed out

I am trying to connect my home machine over ssh. I am trying to connect from different router (i.e client and server are in different geo locations) and trying to connect using server public ip address.

openssh is installed and sshd serivice is enabled and running

➜ systemctl status sshd
● sshd.service - OpenSSH Daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
     Active: active (running) since Fri 2021-03-26 08:09:28 EET; 8s ago
   Main PID: 20877 (sshd)
      Tasks: 1 (limit: 28555)
     Memory: 900.0K
     CGroup: /system.slice/sshd.service
             └─20877 sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups

There is no issue reported under sshd test mode

➜ sudo sshd -t

Filrewall is enabled(I assume it so).

➜ sudo firewall-cmd --zone=public --add-service=ssh
Warning: ALREADY_ENABLED: 'ssh' already in 'public'
success

Not sure what else I am missing but when I try to connect by public ip I get error as

ssh: connect to host xx.xx.xx.x port 22: Operation timed out

Added relevant user too to sshd_config file

AllowUsers    user1 user2

Debug output

➜ ssh -vv xx.xx.xx.x
OpenSSH_8.5p1, OpenSSL 1.1.1k  25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname xx.xx.xx.x is address
debug1: Connecting to xx.xx.xx.x [xx.xx.xx.x] port 22.
debug1: connect to address xx.xx.xx.x port 22: Connection timed out
ssh: connect to host xx.xx.xx.x port 22: Connection timed out

Port 22 is open

➜ netstat -tulpn |grep LISTEN
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -

Any help here is appreciated, as I am trying to connect my home machine over ssh.

Thanks.

Last edited by Anarchish (2021-03-26 09:43:22)

Offline

#2 2021-03-26 08:52:15

Ferdinand
Member
From: Norway
Registered: 2020-01-02
Posts: 338

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

Anarchish wrote:

ssh: connect to host xx.xx.xx.x port 22: Operation timed out

Is that the actual IP-address of your SSH server, or is it the public address, outside your router?
If it is a public address, and your SSH server is on the other side of a router, then you need to configure port forwarding.

Otherwise...

Anarchish wrote:

sudo firewall-cmd --zone=public --add-service=ssh

Note that you must not restart firewalld after you do that, as the rule is not permanent

What's the output of:

  1. # firewall-cmd --get-default-zone

  2. # firewall-cmd --list-services

Offline

#3 2021-03-26 09:10:23

Anarchish
Member
Registered: 2021-03-22
Posts: 5

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

@Albert Camus  It is the public IP-address outside of router.

~
➜ firewall-cmd --get-default-zone
public

~
➜ firewall-cmd --get-default-zone
public

Do you mean to edit sshd_config with below option?

GatewayPorts yes

Last edited by Anarchish (2021-03-26 09:15:19)

Offline

#4 2021-03-26 09:30:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,538

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

Are you trying to connect from the same subnet (ie. yuo and the server are behind the same router, but instead of connecting the local IP you try to connet the routers WAN IP to have it forward to the ssh server)?

Offline

#5 2021-03-26 09:42:30

Anarchish
Member
Registered: 2021-03-22
Posts: 5

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

seth wrote:

Are you trying to connect from the same subnet (ie. yuo and the server are behind the same router, but instead of connecting the local IP you try to connet the routers WAN IP to have it forward to the ssh server)?

I am trying to connect from different router (i.e client and server are in different geo locations) and trying to connect using server public ip address.

Offline

#6 2021-03-26 09:45:09

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,688
Website

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

So, (how) did you configure the port forwarding through the router's NAT firewall sitting in front of the target system?


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#7 2021-03-26 09:53:58

Anarchish
Member
Registered: 2021-03-22
Posts: 5

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

schard wrote:

So, (how) did you configure the port forwarding through the router's NAT firewall sitting in front of the target system?

Yes, I am configuring server so external client could connect to it

Offline

#8 2021-03-26 10:11:49

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,688
Website

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

You also need to configure the router that connects the server to the internet.
How did you do that?

Last edited by schard (2021-03-26 10:12:06)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#9 2021-03-26 12:50:07

Ferdinand
Member
From: Norway
Registered: 2020-01-02
Posts: 338

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

@Anarchish

Am I right in assuming that you can ssh from your ssh server to your ssh server?
E.g. if your ssh server has 10.1.1.1 then

ssh 10.1.1.1

from 10.1.1.1 works?

If so, then you're all set - you just need to get that port forwarding working.

I didn't find a good guide on the Arch wiki, so here's an external link that should be useful:
https://www.howtogeek.com/66214/how-to- … ur-router/

But please, be aware that you're exposing your computer to the evil world.
I would recommend forcing the use of public key authentication: https://wiki.archlinux.org/index.php/Op … entication
And here's how to make keys: https://wiki.archlinux.org/index.php/SSH_keys

This will ensure that only computers with a valid public key can connect. Otherwise any jerk with too much time on his/her hand just needs to guess your password to get in.

Last edited by Ferdinand (2021-03-26 12:52:36)

Offline

#10 2021-03-26 13:10:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,538

Re: ssh: connect to host xx.xx.xx port 22: Operation timed out

nmap -p22 xx.xx.xx.x

Offline

Board footer

Powered by FluxBB