0

I am attempting to open a SSH connection to a Linux console. I want to be able to submit commands to the SSH after opening it (such as ls, cd, etc). How can I do this?

I am using the subprocess to begin the SSH connection.

subprocess.Popen(["C:\ssh\ssh.exe", "SERVER"]);

user2970916
  • 1,146
  • 3
  • 15
  • 37

1 Answers1

0

Instead of doing this at the process level, which is hard and error-prone, my advice is using paramiko or the higher-level fabric.

Fabric contains a lot of helper functions for common automation tasks, such as copying files

loopbackbee
  • 21,962
  • 10
  • 62
  • 97
  • Is there a built-in python library that I would be able to use (such as System.XML)? I am connecting to the Linux machine from a Windows environment. – user2970916 Mar 18 '15 at 17:49
  • @user2970916 as far as I know, no. Even if you use `paramiko`, [using SSH from windows is a though proposition](http://www.paramiko.org/faq.html). Consider running your program in a more friendly operating system if you want to interact with unix systems. – loopbackbee Mar 18 '15 at 17:54
  • I wish I could...but it's a company system that's been setup. Maybe I will have to stick with using subprocess....or maybe another language. – user2970916 Mar 18 '15 at 17:56
  • @user2970916 Any other language will have the same problem, I think. Try [installing paramiko on windows](https://stackoverflow.com/questions/2964658/installing-paramiko-on-windows) and see how it goes - it's better than reinventing the wheel. Installing a VM may be a good option too – loopbackbee Mar 18 '15 at 17:57