Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

connecting to esxi over ssh tunnel #5

Open
ifeatu opened this issue May 8, 2012 · 0 comments
Open

connecting to esxi over ssh tunnel #5

ifeatu opened this issue May 8, 2012 · 0 comments

Comments

@ifeatu
Copy link

ifeatu commented May 8, 2012

I'd like to connect to my esxi server over an ssh tunnel. I tried changing the port (from 22 to 2002) in the esx_vm_create.rb file and declaring "localhost" in my command like so:

knife esx vm create --esx-host localhost --esx-username root --esx-password password --vm-disk mac.vmdk --vm-name test1

but I get:

Connecting to ESX host 127.0.0.1... 
ERROR: Network Error: Connection refused - connect(2)
Check your knife configuration and network settings

Here is the ssh tunnel I established:

ssh -f root@outside_host -L 2002:192.168.1.1:22 -N

Here is proof that the tunnel was established:

root@localhost:# netstat -ant | grep LISTEN | grep 2002
tcp        0      0 127.0.0.1:2002          0.0.0.0:*               LISTEN     

Here is the connection in esx_vm_create.rb (2002 being the localhost port I have the esxi server tunneled through):

def tcp_test_ssh(hostname)
    tcp_socket = TCPSocket.new(hostname, 2002)
    readable = IO.select([tcp_socket], nil, nil, 5)
    if readable
      Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")

Any suggestions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant