At work we have of course a company's-proxy. I need to ssh to some machines out of the company's network. The proxy, though, requires authentication.
Let's assume we have the following variables:
proxy_user="<username I need to authenticate at the proxy>"
proxy_pass="<password I need to authenticate at the proxy>"
proxy_serv="<hostname of the proxy>"
proxy_port=<port of the proxy>
ssh_user="<remote username I need to login on the ssh-machine>"
ssh_serv="<remote password I need to login on the ssh-machine>"
ssh_port=<ssh-port>
When setting the env-variable http_proxy and https_proxy as follows, tools like wget work fine (on the remote server, there is also a web_server installed):
$ export env http_proxy="http://$proxy_user:$proxy_pass@$proxy_serv:$proxy_port"
$ wget $ssh_serv
Connecting to <proxy_serv>... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
But with ssh it does not work:
$ ssh $ssh_user@$ssh_server:$ssh_port
ssh: Could not resolve hostname <ssh_server>:<ssh_port> Temporary failure in name resolution
After googl-ing a little, I found out, that ssh needs a "ProxyCommand". "nc" is not longer recommended here; "ssh -W" shall be used. But I couldn't find an example where authentication was needed. I tried so far:
ssh -o "ProxyCommand='ssh -W %h:%p $proxy_user:$proxy_pass@$proxy_serv:$proxy_port'" $ssh_user@$ssh_serv:$ssh_port
I guess I'm missing something somewhere, but couldn't find a good hint (neither in the manuals, nor on Google).
I hope that some of you guys might help me out.
ProxyJump
option.ssh_serv
is your password. Your second code block suggests that you are passing that value as a command-line argument towget
. Is that really what you mean? (2)export env abc="def"
creates a phantom exported variable called “env
”. You should say justexport abc="def"
. (2b) There are obscure technical reasons why it might be better to sayabc="def"
andexport abc
as two separate commands (optionally, on the same line, separated by a semicolon), but the combined form is usually OK. … (Cont’d)