Connect to host - SSH Tunnel

137 views
Skip to first unread message

Fabricio Cruz

unread,
Dec 24, 2015, 7:49:16 AM12/24/15
to Ansible Project

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

unread,
Dec 24, 2015, 12:08:31 PM12/24/15
to Ansible Project
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



--
Brian Coca

Fabricio Cruz

unread,
Dec 24, 2015, 5:07:47 PM12/24/15
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/_J9nWHVzIPg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8%3DJqBcSuaKEwA8mpoVt6NG2ovsA2tBtmwQ6Y0%3DiWfgOcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Dec 24, 2015, 5:20:08 PM12/24/15
to Ansible Project
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


--
Brian Coca

Tim Fletcher

unread,
Dec 27, 2015, 7:12:02 PM12/27/15
to ansible...@googlegroups.com
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
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.
signature.asc

Alex Leonhardt

unread,
Dec 28, 2015, 7:42:59 AM12/28/15
to ansible...@googlegroups.com

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

Tim Fletcher

unread,
Jan 2, 2016, 6:54:05 AM1/2/16
to ansible...@googlegroups.com
No the tunnel is setup from the bastion to the target to carry a second ssh connection from workstation to target. 

--

Sent from a mobile device

Tim Fletcher
Reply all
Reply to author
Forward
0 new messages