我用python编写了以下代码:
import pxssh
s = pxssh.pxssh()
try:
if not s.login ('x.x.x.x', 'root', 'password'):
print "SSH session failed on login."
print str(s)
else:
print "SSH session login successful"
s.sendline ('uptime')
s.prompt() # match the prompt
print s.before # print everything before the prompt.
s.logout()
except pxssh.ExceptionPxssh, e:
print "SSH conection failed"
print str(e)
我成功地连接了ssh。在
现在,我想向系统中已经存在的文件追加一个密钥(在/root/.ssh/authorized_keys
)
我找不到任何方法来使用pxssh
API来完成它。我怎么做呢。在
在下面的代码中,我假设您已经通过ssh成功地连接到远程机器。我使用这种方法的目的类似,但数据不同。在
希望这有帮助。在
相关问题 更多 >
编程相关推荐