Connect with SSH through a proxy

后端 未结 11 1628
我在风中等你
我在风中等你 2020-12-12 09:03

I have no real idea what I\'m doing here so please bear that in mind if you can help me!

I am trying to connect to my virtual server through a proxy but I can\'t con

11条回答
  •  无人及你
    2020-12-12 09:48

    For windows, @shoaly parameters didn't completely work for me. I was getting this error:

    NCAT DEBUG: Proxy returned status code 501.
    Ncat: Proxy returned status code 501.
    ssh_exchange_identification: Connection closed by remote host
    

    I wanted to ssh to a REMOTESERVER and the SSH port had been closed in my network. I found two solutions but the second is better.

    • To solve the problem using Ncat:

      1. I downloaded Tor Browser, run and wait to connect.
      2. I got Ncat from Nmap distribution and extracted ncat.exe into the current directory.
      3. SSH using Ncat as ProxyCommand in Git Bash with addition --proxy-type socks4 parameter:

        ssh -o "ProxyCommand=./ncat --proxy-type socks4 --proxy 127.0.0.1:9150 %h %p" USERNAME@REMOTESERVER
        

        Note that this implementation of Ncat does not support socks5.

    • THE BETTER SOLUTION:

      1. Do the previous step 1.
      2. SSH using connect.c as ProxyCommand in Git Bash:

        ssh -o "ProxyCommand=connect -a none -S 127.0.0.1:9150 %h %p"
        

        Note that connect.c supports socks version 4/4a/5.

    To use the proxy in git commands using ssh (for example while using GitHub) -- assuming you installed Git Bash in C:\Program Files\Git\ -- open ~/.ssh/config and add this entry:

    host github.com
        user git
        hostname github.com
        port 22
        proxycommand "/c/Program Files/Git/mingw64/bin/connect.exe" -a none -S 127.0.0.1:9150 %h %p
    

提交回复
热议问题