jacobsvante / bgtunnel

Initiate SSH tunnels in the background in python
MIT License
48 stars 16 forks source link

Better connection validation #7

Open jacobsvante opened 10 years ago

jacobsvante commented 10 years ago

Today bgtunnel's connection validation method expects the server to write to stdout on a successful connection. Not every server does this so @hamiltont introduced #6 which allows passing in expect_hello=False to bgtunnel.open and thus bypassing the validation method. This workaround was added to 0.3.6.

Perhaps something is written to stdout but the buffer is not flushed. Look this up.

mpetazzoni commented 10 years ago

@jmagnusson & @hamiltont,

Just a heads up that https://github.com/signalfuse/maestro-ng uses bgtunnel and some users are hitting this issue, as discussed in https://github.com/signalfuse/maestro-ng/issues/63

Any input, fix or workaround would be appreciated!

Cheers

jacobsvante commented 10 years ago

@mpetazzoni I didn't know they were using bgtunnel. I'm clogged with work right now so I'm not sure I will have time this month. In September things will hopefully look up. Any investigation into the issue or a PR is obviously of interest though ;-)

hamiltont commented 10 years ago

If I remember correctly, bgtunnel doesn't run any remote command at all, right? It just opens the connection, expects something like Ubuntu's "hello" message to be printed, and then sits around doing nothing while the tunnel is open in the background. I can't remember why I didn't just add a default command to the remote SSH session, such as ssh <blah> echo Alive, which would guarantee output on every SSH server. Is there a reason this approach would not work inside of bgtunnel, which could then also allow removal of the expect_hello option

jacobsvante commented 10 years ago

@hamiltont That would exit the connection after finishing echo Alive. But maybe there's a flag in SSH to keep it running after that, I don't know really.

mpetazzoni commented 10 years ago

@jmagnusson Yeah we use bgtunnel to offer a SSH-based secure connection to remote Docker daemons (docker-py now supports SSL, but that's sometimes harder to setup).

See the link I posted earlier (signalfuse/maestro-ng#63) for some details and some investigation.