Connect with SSH through a proxy

后端 未结 11 1609
我在风中等你
我在风中等你 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:53

    I was using the following lines in my .ssh/config (which can be replaced by suitable command line parameters) under Ubuntu

    Host remhost
      HostName      my.host.com
      User          myuser
      ProxyCommand  nc -v -X 5 -x proxy-ip:1080 %h %p 2> ssh-err.log
      ServerAliveInterval 30
      ForwardX11 yes
    

    When using it with Msys2, after installing gnu-netcat, file ssh-err.log showed that option -X does not exist. nc --help confirmed that, and seemed to show that there is no alternative option to handle proxies.

    So I installed openbsd-netcat (pacman removed gnu-netcat after asking, since it conflicted with openbsd-netcat). On a first view, and checking the respective man pages, openbsd-netcat and Ubuntu netcat seem to very similar, in particular regarding options -X and -x. With this, I connected with no problems.

    0 讨论(0)
  • 2020-12-12 10:00

    @rogerdpack for windows platform it is really hard to find a nc.exe with -X(http_proxy), however, I have found nc can be replaced by ncat, full example as follows:

    Host github.com
         HostName github.com
             #ProxyCommand nc -X connect -x 127.0.0.1:1080 %h %p
             ProxyCommand ncat --proxy 127.0.0.1:1080 %h %p
         User git
         Port 22
         IdentityFile D:\Users\Administrator\.ssh\github_key
    

    and ncat with --proxy can do a perfect work

    0 讨论(0)
  • 2020-12-12 10:03

    I use proxychains ssh user@host; from proxychains-ng (see https://github.com/rofl0r/proxychains-ng).
    By default it uses a socks4 proxy at 127.0.0.1:9050 but it can be changed in the conf file /etc/proxychains.conf or you can specify another conf file proxychains -f custom.conf

    0 讨论(0)
  • 2020-12-12 10:03

    Try -o "ProxyCommand=nc --proxy HOST:PORT %h %p" for command in question. It worked on OEL6 but need to modify as mentioned for OEL7.

    0 讨论(0)
  • 2020-12-12 10:04

    In my case since I had a jump host or Bastion host on the way, and because the signatures on these bastion nodes had changed since they were imported into known_hosts file, I just needed to delete those entries/lines from the following file:

    /Users/a.abdi-kelishami/.ssh/known_hosts
    

    From above file, delete those lines referring to the bastion hosts.

    0 讨论(0)
提交回复
热议问题