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"]);

2
  • I would assume there is a native ssh implementation in python. Commented Mar 18, 2015 at 16:41
  • I was originally going to do it through SSH, but I think using a native ssh would be smarter. Thanks! Commented Mar 18, 2015 at 16:44

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

4 Comments

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 as far as I know, no. Even if you use paramiko, using SSH from windows is a though proposition. Consider running your program in a more friendly operating system if you want to interact with unix systems.
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 Any other language will have the same problem, I think. Try 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.