Tentando estabelecer o encaminhamento de porta ssh remota:
No meu host remoto, / etc / ssh / sshd_config
GatewayPorts clientspecified
No meu computador local:
ssh -g -R 1234:0.0.0.0:8000 me@my-remote-host
Com depuração, podemos ler:
debug1: Authentication succeeded (publickey).
Authenticated to s1.bux.fr ([178.32.223.76]:22).
debug1: Remote connections from LOCALHOST:1234 forwarded to local address 0.0.0.0:8000
debug2: fd 3 setting TCP_NODELAY
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: remote forward success for: listen 1234, connect 0.0.0.0:8000
debug1: All remote forwarding requests processed
No host remoto, podemos entrar em contato com 1234 port ( WSGIServer/0.2 CPython/3.4.3
é a máquina local 8000 porto):
# http :1234
HTTP/1.0 302 Found
Content-Type: text/html; charset=utf-8
Date: Wed, 19 Oct 2016 13:26:00 GMT
Location: /accounts/login/
Server: WSGIServer/0.2 CPython/3.4.3
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Podemos ver a porta aberta:
# netstat -tupln | grep 1234
tcp 0 0 127.0.0.1:1234 0.0.0.0:* LISTEN 14460/1
tcp6 0 0 ::1:1234 :::* LISTEN 14460/1
Mas, de outra máquina no mundo, não consigo entrar em contato com my-remote-host:1324
:
# http my-remote-host:1234
http: error: ConnectionError: HTTPConnectionPool(host='my-remote-host', port=1234): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0xb6b2fbec>: Failed to establish a new connection: [Errno 111] Connection refused',)) while doing GET request to URL: http://my-remote-host:1234/
Não há firewall no meu host remoto:
# iptables -L
[sudo] password for bux:
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-sshd tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-sshd (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Como descobriu onde está bloqueando?