Hello,
I currently have a host that is accessed saw ssh tunnel, I need to manage that host with ansible. How can I do that?
To connect to the host I use the command: ssh -N -R 10000: localhost: 22 user@hostX .
I added this command on a .sh file and run:
ssh -t user@otherserver “./file.sh”
Thanks.
Brian_Coca
(Brian Coca)
December 24, 2015, 5:08pm
2
just setup this info in your hosts file:
hostx ansible_ssh_host=localhost:10000
then ansible will use the existing tunnel every time to get to hostx
Hello
Thanks for your reply, my scenario is as follows:
hostA — used as a bridge to access the hostX (local machine).
HostC — ansible server you need to manage hostX, perform installations and upgrades using ansible.
It is possible ?
Thank you so much.
Brian_Coca
(Brian Coca)
December 24, 2015, 10:19pm
4
yes, just setup the tunnel and then use ansible as I mentioned in my
previous email.
you can even use ansible to setup the tunnel with a play on the hostC
Would using a netcat tunnel work for you?
We had a similar setup were I used to work and used ssh config to automate the tunnel usage.
Host targethoust
HostName targethost
User myuser
ProxyCommand ssh proxyhost nc %h %p 2> /dev/null
http://backdrift.org/transparent-proxy-with-ssh
Never really looked into it, but if/when using netcat, does that mean that from your proxy host / bastion to the target host, the connection is in clear text? I would assume that to be the case?
Alex
No the tunnel is setup from the bastion to the target to carry a second ssh connection from workstation to target.