You are not logged in.
Following the manpage ssh and official article I succeeded at ssh connection over my local network from one machine to another and vice versa and everyhting worked like a charm.
I connected to local machine using command knowing my Local IP
username@192.168.0.103However, when I try to establish ssh conenction to remote server, knowing the Public IP via command
curl ifconfig.me
I get an errors which says either "connection timed out" or "connection refused". I configured port forwarding 22 port to local IP address 192.168.0.103, also tried changing port to 443 still no luck.
To connect to a server, run:
ssh -p port user@server-address
I'm not sure what I'm doing wrong maybe I misunderstood what actually "server-address" is?
Output of netstat
netstat -anltp | grep LISTEN
tcp6 0 0 :::22 :::* LISTEN - Content of /etc/ssh/sshd_config
AuthorizedKeysFile .ssh/authorized_keys
ChallengeResponseAuthentication no
UsePAM yes
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
PrintMotd no
Subsystem sftp /usr/lib/ssh/sftp-serverContent of /etc/ssh/ssh_config
Host localhost
ForwardAgent yes
ForwardX11 yes
Port 22When trying to connect to remote PC, e. g. my Public IP "144.123.12.12"
ssh -vvv username@144.123.12.12
OpenSSH_7.9p1, OpenSSL 1.1.1b 26 Feb 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 144.123.12.12 is address
debug2: ssh_connect_direct
debug1: Connecting to 144.123.12.12 [144.123.12.12] port 22.
debug1: connect to address 144.123.12.12 port 22: Connection refused
ssh: connect to host 144.123.12.12 port 22: Connection refusedLast edited by assertion9 (2019-04-29 10:22:27)
Offline
Output of
nmap [local IP]
nmap [public IP]However, it would seem ssh is only listening on IPv6 - is that really your complete /etc/ssh/sshd_config ?
And itr and sorry but I've to ask: in that case, are you actually running archlinux?
Offline
Output of
nmap [local IP] nmap [public IP]However, it would seem ssh is only listening on IPv6 - is that really your complete /etc/ssh/sshd_config ?
And itr and sorry but I've to ask: in that case, are you actually running archlinux?
Edited sshd_config
# uname -a
Linux hostname 5.0.6-arch1-1-ARCH #1 SMP PREEMPT Wed Apr 3 09:35:20 UTC 2019 x86_64 GNU/Linux# nmap [local IP]
Nmap scan report for 192.168.0.104
Host is up (0.00017s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds# nmap [public IP]
Nmap scan report for 144.123.12.12.broadband.kyivstar.net (144.123.12.12)
Host is up (0.0030s latency).
All 1000 scanned ports on 144.123.12.12.broadband.kyivstar.net (144.123.12.12) are filtered
Nmap done: 1 IP address (1 host up) scanned in 21.35 secondsSo ssh port is obviously closed for public ip, can I troubleshoot to find more specific information?
Offline
That's in your router, it doesn't forward the port (or any port)
Is this maybe a router cascade, possibly https://en.wikipedia.org/wiki/Carrier-grade_NAT (ie. you don't get a "real" IPv4 address, in that case you*ll never be able to access it from outside via IPv4, but IPv6 should™ work)
---
Also the netstat output remains odd, by default there should be
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN and your config does not alter the relevant value.
Offline
I don't think i understood exactly your case.
curl has nothing to do with ssh. I'm guessing you want to connect from internet to an ssh server behind a router's firewall at the default 22 port. The router assigns to each private (home) host a local ip of the type 192.168.1.<something>. At your router's firewall settings you should allow incoming TCP/UDP connections to your local machine's (ssh server's) IP. Also in the sshd_config file i guess you should comment out the "#ListenAdress 0.0.0.0" line in order to allow someone to connect from the internet. Also you should run "systemctl status sshd" to make sure the ssh server is running.
Last edited by saavedra29 (2019-04-13 17:06:33)
Offline
I don't think i understood exactly your case.
"curl ifconfig.me" will print your WAN IP, he already suggested to have enabled port forwarding for port 22 and something™ is certainly listening on port 22 and he asserted that he can ssh into the machine inside the subnet.
Just uncommenting "#ListenAdress 0.0.0.0" will do nothing because that's the default behavior anyway (though somehow the open port on IPv4 doesn't show up in his netstat - and I cannot explain that from the presented information)
Offline