1
WindowsからLinuxマシン上でいくつかのリモートコマンドを実行するpythonスクリプトを作成しようとしています。私はSSH接続ライブラリとしてparamikoを使い、リモートマシン上でいくつかのfabスクリプトを実行しています。Windows上でparamikoでのエージェント転送を使用する
しかし、fabスクリプトは他のマシンに接続するので、エージェント転送を使用する必要があります。含む
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python27\lib\site-packages\paramiko\agent.py", line 117, in run
raise AuthenticationException("Unable to connect to SSH agent")
私がコピーした逐語的にいくつかの例:私は、コードを実行するたびにしかし、私はこのエラーが出るそれだけに転送されるように私は、ローカル認証エージェントを設定する必要がありますように見えますhttps://gist.github.com/toejough/436540622530c35404e6
何もないが、私はそれを行う方法を見つけることができません。
マイコード:
privkey = paramiko.RSAKey.from_private_key_file(PrivKeyDirFile, password = PrivKeyPw)
# Start the client
client = paramiko.client.SSHClient()
client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
client.load_system_host_keys()
client.connect(hostname = Host, username = User, pkey = privkey)
# get a session
sshChannel = client.get_transport().open_session()
# set up the agent request handler to handle agent requests from the server
paramiko.agent.AgentRequestHandler(sshChannel) # <--UNDOCUMENTED??!!
# get a shell
sshChannel.get_pty()
sshChannel.invoke_shell()
# SNIP
sshChannel.send
("command-which-invokes-fab-script\n")
# error now happens
助けてください!
われわれは大量のコマンドの送受信を必要とするインタラクティブなセッションを実行します。私たちの読書と実験から、exec_commandは単一のコマンドではより有用でしたが、チャネルはよりインタラクティブな方法にとってより有用でした。 @voiceofthemany - – voiceofthemany
'exec_command'を使うときも同じエラーが出ますか?もしそうでなければ、 'exec_command'のソースコードとあなたが書いたものを比較したいかもしれません。 – ArtOfWarfare
はい、exec_commandを使用しているときに "problem"コマンドと同じエラーが発生しました。 – voiceofthemany