我正在尝试从公司网络访问Internet上的SSH服务器。必须通过服务器代理与外部Internet的所有连接,该服务器在每个请求中检查每个客户端的NTLM哈希。我正在为此使用Cntlm,而且仅工作了一半。对于基于HTTP的连接,它工作正常,但对于SSH样式的连接,则行不通。我知道这是因为,我可以连接到Sublime Text的Package Control插件来获取和更新插件。但是,我无法使用Cntlm的隧道配置将其用于SSH进入服务器。
查看Cntlm的日志,可以看到以下内容...
cntlm: PID 1460: 127.0.0.1 TUNNEL ts.io:443
Tunneling to ts.io:443 for client 6...
Starting authentication...
NTLM Request:
Domain: domain.tld
Hostname: D-HOSTNAME
Flags: 0xA208B205
NTLM握手(类型1)
Sending PROXY auth request...
Proxy-Connection => keep-alive
Proxy-Authorization => NTLM [REDACTED]
Content-Length => 0
读取PROXY身份验证响应...
HEAD: HTTP/1.1 407 Proxy Authentication Required ( Access is denied. )
Via => 1.1 FOLLICLE
Proxy-Authenticate => NTLM [REDACTED]
Connection => Keep-Alive
Proxy-Connection => Keep-Alive
Pragma => no-cache
Cache-Control => no-cache
Content-Type => text/html
Content-Length => 0
NTLM Challenge:
Challenge: 4AC9211DC2875FFF (len: 178)
Flags: 0xA2898205
NT domain: NTDOMAIN
Server: PROXY
Domain: domain.tld
FQDN: proxy.domain.tld
TLD: domain.tld
TBofs: 64
TBlen: 114
ttype: 0
NTLMv2:
Nonce: CB4E6617ABF19C24
Timestamp: -1581153408
NTLM Response:
Hostname: 'D-HOSTNAME'
Domain: 'domain.tld'
Username: 'username'
Response: '[REDACTED]' (162)
Response: '[REDACTED]' (24)
Sending real request:
Proxy-Connection => keep-alive
Proxy-Authorization => NTLM [REDACTED]
最后我得到了...
Reading real response:
HEAD: HTTP/1.1 200 Connection established
Via => 1.1 PROXY
Connection => Keep-Alive
Proxy-Connection => Keep-Alive
Ok CONNECT response. Tunneling...
tunnel: select cli: 6, srv: 7
Joining thread 537272664; rc: 0
因为防火墙仅允许通过代理服务器从端口80和端口443连接到外部Internet,所以我将SSH服务器重新配置为接受来自端口443的连接。
我看到的问题是,当我尝试进行SSH连接时,使用SFTP插件时,连接会从Sublime Text中报告为连接超时。使用PuTTY可立即产生效果PuTTY Fatal Error: Server unexpectedly closed network connection
。Google Chrome扩展程序安全外壳为我提供了以下更详细的错误ssh_exchange_identification: Connection closed by remote host
NaCl plugin exited with status code 255.
Cntlm配置
# The username of the client you wish to masquerade as.
#
Username username
# The domain name of the network you are connected too.
#
Domain domain.tld
# The Password, LM, NTLM, or NTLMv2 Password.
# You should leave this blank and then start cntlm
# with the -M arg to get the hash information, then
# place that information here.
#
PassNTLMv2 [REDACTED]
# Specify the netbios hostname cntlm will send to the parent
# proxies. Normally the value is auto-guessed.
#
Workstation D-HOSTNAME
# List of parent proxies to use. More proxies can be defined
# one per line in format <proxy_ip>:<proxy_port>
#
Proxy PROXY:8080
# Specify the port cntlm will listen on
# You can bind cntlm to specific interface by specifying
# the appropriate IP address also in format <local_ip>:<local_port>
# Cntlm listens on 127.0.0.1:3128 by default
#
Listen 3128
# Use -M first to detect the best NTLM settings for your proxy.
# Default is to use the only secure hash, NTLMv2, but it is not
# as available as the older stuff.
#
# This example is the most universal setup known to man, but it
# uses the weakest hash ever. I won't have it's usage on my
# conscience. :) Really, try -M first.
#
Auth NTLMv2
# Tunnels mapping local port to a machine behind the proxy.
# The format is <local_port>:<remote_host>:<remote_port>
#
Tunnel 1443:ts.io:443
这是我用于Cntlm中的隧道的配置部分。
腻子配置
IP:PORT localhost:1443
这就是我用于PuTTY连接的内容。
崇高文字
"http_proxy": "http://localhost:3128",
有什么想法可以解决这个问题吗?我想通过SSH进入我的服务器,必须有一种方法仅使用Cntlm的隧道功能来做到这一点,我只是不知道自己在做什么错。
我可以告诉您,我可以从公司网络外部使用端口443连接到我的SSH服务器。