mwilliamson / spur.py

Run commands and manipulate files locally or over SSH using the same interface
BSD 2-Clause "Simplified" License
267 stars 37 forks source link

Remote Windows host support #63

Closed SeanXu1984 closed 7 years ago

SeanXu1984 commented 7 years ago

Hi,

Does this spur.py support running command via SSH against a remote Windows host? I've tried both sh and minimal shell types without any success. The implementation looks very Linux to me.

from spur import SshShell from spur.ssh import SshProcess, MissingHostKey from spur.results import ExecutionResult

shell = SshShell(hostname="10.108.43.25", username="administrator", password="Password123!", port=22, missing_host_key=MissingHostKey.accept, look_for_private_keys=False, shell_type=spur.ssh.ShellTypes.minimal) re = shell.run(['cmd','/c','ipconfig']) print re.output

spur.results.RunProcessError: return code: 4294967295 output: b'Unable to execute command or shell on remote system: Failed to Execute process.\r\n' stderr output: b''

mwilliamson commented 7 years ago

If the Windows host is running an SSH server and the shell is bash, then things should work fine. If the shell isn't bash, then it's possible that some more tweaking is required. What SSH server and shell are being used are on the host?

SeanXu1984 commented 7 years ago

It is a Windows Server 2008 R2 with FreeSSHd installed. I didn't install any shell explicitly on the remote Windows host, though.

mwilliamson commented 7 years ago

If you can work which commands work when issuing commands manually, then you should be able to write another shell type to work with whatever's expected.

SeanXu1984 commented 7 years ago

Ah, good idea ... I will try to create my own Shell Type and pass it to spur.SshShell. Thanks