473,659 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execute Commands on Remote Computers over Network

I have been researching this topic and come up with some code to make
it work. It uses SSL and requires the 3rd party package Paramiko (which
requires PyCrypto). However, at this moment I have no network to test
the code on! Trying to connect to localhost (127.0.0.1) fails. Before I
buy network components, I want to be sure that this code will work.
Will someone with two networked computers try it out for me? Thanks!
Code:

def remotely_execut e_command(ipadd r, port, user, passwd=None, cmd):
import paramiko
transport = paramiko.Transp ort(ipaddr + ":" + port)
transport.conne ct(username=use r, password=passwd )
channel = transport.open_ session()
channel.exec_co mmand(cmd)
print "Command " + cmd + " executed by user " + user + " with
password " + passwd + " at " + host + ":" + port

Jun 27 '06 #1
15 7515
In article <11************ **********@c74g 2000cwc.googleg roups.com>,
"dylpkls91" <dp******@pacbe ll.net> wrote:
I have been researching this topic and come up with some code to make
it work. It uses SSL and requires the 3rd party package Paramiko (which
requires PyCrypto).


Why not just spawn an invocation of SSH?
Jun 27 '06 #2

Lawrence D'Oliveiro wrote:
In article <11************ **********@c74g 2000cwc.googleg roups.com>,
"dylpkls91" <dp******@pacbe ll.net> wrote:
I have been researching this topic and come up with some code to make
it work. It uses SSL and requires the 3rd party package Paramiko (which
requires PyCrypto).


Why not just spawn an invocation of SSH?


@Dennis: yes, I know, but I wasn't thinking, and it doesn't solve the
problem.

@Lawrence: I'm sorry, but I'm a newbie. Can you explain what this
means, and how I could do it in Python? Thank you very much.

Jun 27 '06 #3
In article <11************ **********@u72g 2000cwu.googleg roups.com>,
"dylpkls91" <dp******@pacbe ll.net> wrote:
Lawrence D'Oliveiro wrote:
In article <11************ **********@c74g 2000cwc.googleg roups.com>,
"dylpkls91" <dp******@pacbe ll.net> wrote:
>I have been researching this topic and come up with some code to make
>it work. It uses SSL and requires the 3rd party package Paramiko (which
>requires PyCrypto).


Why not just spawn an invocation of SSH?


Can you explain what this means, and how I could do it in Python?


SSH is the standard means of remotely executing commands on one *nix
system from another <http://www.openssh.com/>. It is included with all
self-respecting *nix systems these days. You can set up a trust
relationship between particular accounts on two systems, so one can
connect to the other without a password. All communication is encrypted
to lock out eavesdroppers.
Jun 29 '06 #4
Lawrence D'Oliveiro wrote:
In article <11************ **********@u72g 2000cwu.googleg roups.com>,
"dylpkls91" <dp******@pacbe ll.net> wrote:

Lawrence D'Oliveiro wrote:
In article <11************ **********@c74g 2000cwc.googleg roups.com>,
"dylpkls91" <dp******@pacbe ll.net> wrote:
I have been researching this topic and come up with some code to make
it work. It uses SSL and requires the 3rd party package Paramiko (which
requires PyCrypto).

Why not just spawn an invocation of SSH?


Can you explain what this means, and how I could do it in Python?

SSH is the standard means of remotely executing commands on one *nix
system from another <http://www.openssh.com/>. It is included with all
self-respecting *nix systems these days. You can set up a trust
relationship between particular accounts on two systems, so one can
connect to the other without a password. All communication is encrypted
to lock out eavesdroppers.


Also note that Cygwin gives you openssh in a Unix-shell-like
environment. Has its own Python too, though you don't do things in
Cygwin for performance, usually.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Love me, love my blog http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Jun 29 '06 #5
I'm sorry, I should have clarified. I want to execute commands on
networked computers running <i>Windows XP</i>. Thank you for you
concern anyway. Does this mean that the Paramiko module only works on
Unix systems?

Jul 12 '06 #6
dylpkls91 wrote:
I have been researching this topic and come up with some code to make
it work. It uses SSL and requires the 3rd party package Paramiko (which
requires PyCrypto). However, at this moment I have no network to test
the code on! Trying to connect to localhost (127.0.0.1) fails.
Where is the code that is supposed to receive this connection? There
has to be something running on the target PC to accept incoming
commands. Paramiko appears to use SSH, which (as far as I know)
connects to a computer running an sshd program or equivalent and
executes commands via that program. If there's no sshd running on the
target, you can't do anything.

--
Ben Sizer

Jul 13 '06 #7

Ben Sizer wrote:
Paramiko appears to use SSH, which (as far as I know)
connects to a computer running an sshd program or equivalent and
executes commands via that program. If there's no sshd running on the
target, you can't do anything.
Thanks for the clarification. Can I get 'sshd' or an equivalent for
Windows?

Jul 13 '06 #8
Thank you all for your responses.

I have managed to figure out a solution using XML RPC which fits my
needs perfectly.

Jul 13 '06 #9
On 2006-07-13 20:46:16, dylpkls91 wrote:
Thank you all for your responses.

I have managed to figure out a solution using XML RPC which fits my
needs perfectly.
BTW, if you want to test networking between two machines on one single
(Windows) computer, try VirtualPC. (Free from MS.)

Gerhard

Jul 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1679
by: jake | last post by:
How can I copy a file securely (encryption) from remote computers easily (Mac and Linux) to my Win 2000 Server once a day?
15
14047
by: Madhanmohan S | last post by:
Hi All, I want to run a command line appplication from C#. When i start the application, it will go into specific mode. After that, i have to give commands to use the application. How Can This Be Done in C#.... Thanks and Regards, S.Madhanmohan
1
1814
by: Faraz | last post by:
Hey guys. How cam I interface with the environment in C#. I want to execute commands in a (separate) process, just like java Runtime.exec(string command) does. Thanks in advance,
3
1461
by: Just D. | last post by:
I know that writing ASPX app we easily can get all required information about remote machine and network right from the user's browser using this request: NameValueCollection coll = Request.ServerVariables; But what if we write a Web Service? What can we do in this case? How can we get the remote machine IP and the HostName for example? Do we have any way that can be used from the Web Service for that? I know that I probably can get...
5
1095
by: tracid83 | last post by:
Hello, I would like to get information from remote computer and printer connected to network. I don't want to use windows WMI service. Thank you for your help.
15
2808
by: tmp123 | last post by:
Hello, Thanks for your time. We have very big files with python commands (more or less, 500000 commands each file). It is possible to execute them command by command, like if the commands was typed one after the other in a interactive session?
1
1972
by: Hishaam | last post by:
How to execute commands in internal zones of solaris using python running from the global zone ? i tried -- 1os.popen("zlogin <zone1>") 2os.popen("zonename") the 2nd command executes back into the global zone and not into the internal zone can anyone help?
6
13093
by: samvb | last post by:
Hello Guys, Do you know any programs that can install applications to remote computers without the users knowledge/interaction? And any way to deply windows to remote computers/clients from server? Thanks for ur help.
1
1793
by: nthato | last post by:
Hi I am trying to create a script that will execute commands on several remote servers and I am having problems to increment my positional variables. I the a simple way of doing this???
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.