2017-10-08 92 views
0

我写了一个脚本,使用ssh连接(单点登录服务器)从那里我想连接一个节点的单个连接服务器。但我的问题是,当我通过ssh invoke_shell发送命令时,我可以在输出中看到它,但命令没有执行。任何有关单连接和paramiko的帮助将不胜感激。使用paramiko SSH到singleconnect(SSO)服务器

#!/usr/bin/env python 


import paramiko 
import time 

ssh = paramiko.SSHClient() 
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
ssh.connect("host",port=2222,username="username",password="pass") 
remote_con = ssh.invoke_shell() 
print "Interactive SSH session established" 
output = remote_con.recv(5000) 
remote_con.send("device_ip_here_to_connect_from_SSO \n") 
print output 
time.sleep(3) 
output = remote_con.recv(5000) 
print output 
+0

请[编辑]你的问题,包括这个脚本或它的相关部分。 – Kenster

+0

编辑了添加的问题和脚本。 –

回答

0

确保发送命令,当您使用send('command\n'),而不是send('command')

+0

我确定使用它发送(“command \ n”)这种方式。奇怪的是,当我读取输出时,它看起来应该在哪里,但事后没有响应。 –

0

我找到了解决办法,

的问题发送命令这样

remote_con.send("device_ip_here_to_connect_from_SSO \n") 

它应该是这样的

remote_con.send("device_ip_here_to_connect_from_SSO \r")