2017-10-08 90 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")