I'm using openSSH to make ssh connection between test machine (Windows XP) and controller machine (win 7). I've configured the ssh server on test machine and I'm able to get the ssh session and run command. When i run command in this ssh session i get o/p displayed in the putty session, however when i use the same command and try to retrieve the o/p I'm getting no value.
I've installed the openssh on my XP box, this is the version OpenSSH for Windows v3.8.1p1-1.
This is how I configured it for running the ssh on windows
C:\Documents and Settings\Administrator>cd c:\OpenSSH
C:\OpenSSH>cd bin
C:\OpenSSH\bin>mkgroup -l >> ..\etc\group
C:\OpenSSH\bin>mkpasswd -l -u administrator >> ..\etc\passwd
C:\OpenSSH\bin>net start opensshd
The requested service has already been started.
Below is my code for the same
import paramiko
class TestSSH():
def __init__(self):
self.ip = "172.xxx.xxx.xxx"
self.user = "Administrator"
self.password = "passpass"
def run(self):
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(
self.ip,
username = self.user,
password = self.password
)
std_in, std_out, std_err = ssh_client.exec_command("dir")
print std_out.read()
obj = TestSSH()
obj.run()
this is the o/p i'm getting in putty session -
Directory of C:\Documents and Settings\Administrator
11/14/2013 03:11 PM <DIR> .
11/14/2013 03:11 PM <DIR> ..
11/14/2013 03:12 PM <DIR> Desktop
07/27/2011 06:00 PM <DIR> Favorites
11/14/2013 03:11 PM <DIR> hemant
07/27/2011 06:00 PM <DIR> My Documents
07/27/2011 11:12 PM <DIR> Start Menu
0 File(s) 0 bytes
7 Dir(s) 39,932,612,608 bytes free
C:\Documents and Settings\Administrator>
however I'm not getting any o/p
I've tried with other sshutility for windows name freeSSHd, I'm able to connect through putty and execute command, however, I'm only able to connect but not execute the command. I'm getting the following error with the freeSSHd server.
Unable to execute command or shell on remote system: Failed to Execute process.
This o/p is came into std_out not in std_err variable.
'passpass'is your real password, it's probably not a LAN that needs much security…)std_err.read(), just to make sure thedirisn't somehow failing?