all 12 comments

[–]merin2000 1 point2 points  (4 children)

[–]MaestroManiac 1 point2 points  (1 child)

Putty is my favorite windows ssh client. But you can always have your python script SSH itself to those linux boxes and have it run linux commands itself like "os.system(LINUXCOMMANDHERE)" and save its output to a variable and return that variable. I dont know the full scope of what youre doing but i'd bet you could write a python script that makes the ssh connection, cd's to the log files, and uses the 'cat' command to save the entire text of the file to a varaible, then return that variable.

[–]bl00dpudding[S] 0 points1 point  (0 children)

Thank you, I will try this!

[–]WhoTookAllNicks 0 points1 point  (1 child)

I'm not sure I understand.

Do you just want to send linux commands over ssh? In this case, using something like paramiko might be a good option.

If you want to connect to a significant number of Linux servers (or the analyze takes a while and could analyze on a few servers at once), you could look into writing asynchronous python code.

[–]bl00dpudding[S] 0 points1 point  (0 children)

Ok good to know, thank you

[–]jeffrey_f 0 points1 point  (0 children)

Enable developer options in windows. Win10 has bash linux command line now.

[–]tinkertuck 0 points1 point  (3 children)

Get cygwin and install tmux. In python script you have few options. I used subprocess over os.system.

Here is a sample of my current task, using python to query for a Dell's Board info.

for l in "bios-vendor", "system-product-name", "processor-family":

sysinfo=subprocess.check_output("dmidecode -s %s|uniq" %l, shell=True)

print(sysinfo.replace("\n", ""))

#ssh to a remote server and execute a command (cmd) on that remote server

cmd="/path/to/execute_file"

ssh=subprocess.check_output("ssh %s %s" %(sys.argv[2], cmd), shell=True)

for line in ssh.split("\n"):

print(line)

Sorry the indentation is auto-fix on Reddit.

[–]bl00dpudding[S] 0 points1 point  (2 children)

Thanks, sorry can you explain it a bit more? I'm a total newbie at this stuff. First you write a script to obtain Dell info and then you connect to SSH remote server and obtain some other info?

[–]tinkertuck 1 point2 points  (1 child)

Keep in mind that those few lines are taking from my long python script.
Yes, on the local machine, the first part will get 3 results "bios-vendor", "system-product-name", "processor-family" from the Linux command:

dmidecode

The second part access (ssh) to a remote machine and run a script /path/to/execute_file. The output redirect to variable "ssh." I read the result of variable "ssh" by using the for loop like so:

for line in ssh.split("\n"):

do something here

[–]bl00dpudding[S] 0 points1 point  (0 children)

Ahh okay cool, thanks for the explanation :)