如果只能從server1訪問server2,我該如何ssh兩次?在主機內構建兩次ssh
fabfile.py:
from fabric.api import run
from fabric.api import env
env.hosts = ['[email protected]']
env.use_ssh_config = True
def dothis():
run('ssh [email protected]')
run('ls -al') # this should be done on [email protected]
當我運行:
晶圓廠dothis,我得到:
[[email protected]] Executing task 'dothis'
[[email protected]] run: ssh [email protected]
[[email protected]] out: Permission denied (publickey).
[[email protected]] out:
[[email protected]] out:
Fatal error: run() received nonzero return code 255 while executing!
Requested: ssh [email protected]
Executed: /bin/bash -l -c "ssh [email protected]"
Aborting.
Disconnecting from [email protected] done.
我如何告訴面料env.user_ssh_config =真Server2上沒有在server1上保存另一個結構文件?
的方式,我通常訪問Server2上是這樣的:
ssh [email protected] ssh [email protected]
現在不好意思,想做一個答覆嗎?那需要2個任務嗎? – Neeran
添加爲答案。只有一項任務需要完成你的問題。 – Johnsyweb
或者,您可以嘗試使用'server1.com'中的[sshpass](http://www.cyberciti.biz/faq/noninteractive-shell-script-ssh-password-provider/)運行該命令以跳過主機密鑰檢查。你的命令應該是這樣的:'sshpass -p password ssh -o StrictHostKeyChecking = no -o CheckHostIP = no [email protected]「ls -al」' – Milo