Reputation: 1098
( Related Question: PuTTY configuration equivalent to OpenSSH ProxyCommand but it is for a single ppk/pem file... my problem is slightly different.)
I am trying to use PuTTY to get an SSH connection to my servers. These servers allow incoming SSH connection only from bastion server(another specific server) only.
Using Linux this is no problem with the ssh command...I have achieved that in Linux like this... (~/.ssh/config)
HOST myprod-bastion
IdentityFile ~/.ssh/pemfile/myprod-bastion.pem
User bastion-user
Hostname X.X.X.X
HOST mywebserver
IdentityFile ~/.ssh/pemfile/myweserver.pem
User produser
Hostname 192.168.Y.Y
ProxyCommand ssh myprod-bastion -W %h:%p
From my terminal, I just need to execute following command:
ssh mywebserver
Anyone knows how to use such a config in PuTTY? Appreciate your help in advance. :)
Upvotes: 2
Views: 1153
Reputation: 441
I had exactly the same problem, which you describe and solved it the following way (based on (Martin Prikryll's answer in the thread you also referenced). (See the PuTTY User Manual for details about PuTTYgen, Pageant or plink, which are reqired for this solution. All tools come along with PuTTY.)
Convert both keys with PuTTYgen to the PuTTY .ppk file format You do this by loading your .pem file into PuTTYgen and save the private key.
Start Pageant and add the private .ppk key of bastion-user@myprod-bastion.
Configure the session parameters in the PuTTY GUI.
In the tabs
In your case, you can leave the fields "Proxy Hostname", "Port" and "Username" blank, and you don't need a password, since you provide a private key. The full command in "local proxy command" field is:
plink -ssh [email protected] -P YYY -batch -agent -nc %host:%port
Parameters explained:
You can start your session from command line very similar to *nix with
plink mywebserver
Upvotes: 1
Reputation: 31
I'm not sure if you still need this answered. But since I came across this asking the same question, I'll share my solution.
This site gave me the basis for the approach: (warning link may be broken) https://www.math.ucla.edu/computing/kb/creating-ssh-proxy-tunnel-putty
I had to create two connections with PuTTY; One for the Bastion, and one for the other box (mywebserver).
Create your connection to the Bastion host, specifying the hostname, port, and other necessary information depending on your setup.
Then under Connection > SSH > Tunnels
, add a forwarded port. Set the source port (for ex: 31415
), and write that value down. Set the type to Dynamic
and leave Auto
selected.
PuTTY Setup for Forwarded Port
Be sure to save this as a configuration.
Next enter the credentials to setup the connection to the other box (mywebserver). The additional step you need to take here is to connect it to the first configuration by way of proxy.
Under Connection > Proxy
, select a proxy type of SOCKS 5
, set the proxy hostname to be localhost and set the port to be the same as created in the previous step (in this example: 31415
). The rest of the settings can be left the same.
Now, all you need is to start the first connection to the Bastion host and then start the connection to the other box (mywebserver).
Upvotes: 3