「pythonssh」をグーグルで検索しました。pexpect
ssh(パスワード付き)を使用してリモートコンピュータにアクセスできる素晴らしいモジュールがあります。
リモートコンピュータが接続された後、他のコマンドを実行できます。ただし、Pythonで結果を再度取得することはできません。
p = pexpect.spawn("ssh user@remote_computer")
print "connecting..."
p.waitnoecho()
p.sendline(my_password)
print "connected"
p.sendline("ps -ef")
p.expect(pexpect.EOF) # this will take very long time
print p.before
私の場合、結果を得るにはどうすればよいps -ef
ですか?