1
1つのサーバーから別のサーバーに単純なssh(端末を使用)を実行するとうまくいきますが、pexpectモジュールを使用してPythonアプリケーションからsshを使用しようとすると、そうするために。何が起こっているのでしょうか?sshを実行するときにpexpectのpythonモジュールからアクセス許可が拒否される
Traceback (most recent call last):
File "pef.py", line 8, in <module>
s.login(hostname, username, password)
File "/usr/local/pythonbrew/pythons/Python-2.7.10/lib/python2.7/site-packages/pexpect/pxssh.py", line 316, in login
raise ExceptionPxssh('permission denied')
pexpect.pxssh.ExceptionPxssh: permission denied
私はこれがpexpectモジュールの古いバージョンのバグであるpexpect文書に
from pexpect import pxssh
import getpass
s = pxssh.pxssh()
s.force_password = True
hostname = raw_input('hostname: ')
username = raw_input('username: ')
password = getpass.getpass('password: ')
s.login(hostname, username, password)
s.sendline('uptime') # run a command
s.prompt() # match the prompt
print(s.before) # print everything before the prompt.
s.sendline('ls -l')
s.prompt()
print(s.before)
s.sendline('df')
s.prompt()
print(s.before)
s.logout()