You are not logged in.
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 startupsThere is no issue reported under sshd test mode
➜ sudo sshd -tFilrewall is enabled(I assume it so).
➜ sudo firewall-cmd --zone=public --add-service=ssh
Warning: ALREADY_ENABLED: 'ssh' already in 'public'
successNot 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 outAdded relevant user too to sshd_config file
AllowUsers user1 user2Debug 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 outPort 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
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...
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:
# firewall-cmd --get-default-zone
# firewall-cmd --list-services
Offline
@Albert Camus It is the public IP-address outside of router.
~
➜ firewall-cmd --get-default-zone
public
~
➜ firewall-cmd --get-default-zone
publicDo you mean to edit sshd_config with below option?
GatewayPorts yesLast edited by Anarchish (2021-03-26 09:15:19)
Offline
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
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
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
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
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
@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.1from 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
nmap -p22 xx.xx.xx.xOffline