python - Fabric ssh twice within host -


how ssh twice if server2 can accessed server1?

fabfile.py:

from fabric.api import run fabric.api import env  env.hosts = ['host@server1.com']  env.use_ssh_config = true  def dothis():     run('ssh host@server2.com')     run('ls -al') # should done on host@server2.com 

when run:

fab dothis, get:

[host@server1.com] executing task 'dothis' [host@server1.com] run: ssh host@server2.com [host@server1.com] out: permission denied (publickey). [host@server1.com] out:  [host@server1.com] out:   fatal error: run() received nonzero return code 255 while executing!  requested: ssh host@server2.com executed: /bin/bash -l -c "ssh host@server2.com"  aborting. disconnecting host@server2.com... done. 

how tell fabric env.user_ssh_config = true on server2 without keeping fabric file on server1?

the way access server2 this:

ssh host@server1.com ssh host@server2.com 

it looks you're trying use "server1.com" gateway host "server2.com", , presumably others:

from fabric.api import run fabric.api import env  env.gateway = 'host@server1.com' env.hosts = ['host@server2.com']  env.use_ssh_config = true  def dothis():     run('ls -al')  # should done on host@server2.com 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -