How to login to a remote desktop using python??

Python could be (is ?) the easiest way to write
networking code.
In this forum category we discuss specifically network code.

Moderators: KDoiron, ChrJim, mawe, python

How to login to a remote desktop using python??

Postby pareshverma91 on Fri Mar 05, 2010 6:49 am

The problem is that I want login to a remote pc using ssh through a python script.
I don't want to use any ssh-keys (rsa keys,dsa keys etc.) nor do I want to use some extra module not incorporated in python standard libraries (telnet etc I guessed it is used in this from internet although I could not make out anything and it wasn't in my python documentation).
I am a beginner in python and would not mind any length of code until it is done entirely using python standard libraries.
(It's not sth. I require desperately but I want to know the way it is done..)

Sorry for being posting such descriptive and strange question....
Hoping someone would give a meaningful reply to it...
Thanks
pareshverma91
Python Fan
Python Fan
 
Posts: 2
Joined: Fri Mar 05, 2010 6:46 am

Re: How to login to a remote desktop using python??

Postby jjfattz on Fri Mar 05, 2010 2:27 pm

If you have OpenSSH installed and it is added to your Windows "path", you could do something like this:

Code: Select all
import subprocess
process = subprocess.Popen("ssh example.com dir", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

output,stderr = process.communicate()
status = process.poll()
print output

(above snippet is from Neil over at Stackoverflow.com)

You could use the subprocess function to deal with user names and passwords as well.

I personally prefer third party packages, like paramiko, to perform SSH. Here is a site that makes the implementation of paramiko easy.

http://commandline.org.uk/python/sftp-python-really-simple-ssh
jjfattz
Python User
Python User
 
Posts: 88
Joined: Wed Feb 24, 2010 10:54 pm

Re: How to login to a remote desktop using python??

Postby pareshverma91 on Sat Mar 06, 2010 2:31 am

But could you please tell in terms of a linux with no third party modules.
I want to do it with the standard python.
Its not practical I know, but I want it to be a learning experience..
pareshverma91
Python Fan
Python Fan
 
Posts: 2
Joined: Fri Mar 05, 2010 6:46 am

Re: How to login to a remote desktop using python??

Postby pythonista on Sat Mar 06, 2010 10:27 am

openssh client is installed by default on just about every mainstream distro out thereand should be already in the path. Did you try his example?

When you say you don't want to use any 3rd party module, I assume you mean no 3rd party python modules...the openssh client isn't a python module is just a separate program.

If you want to code your own ssh client in pure python from scratch be prepared for a lot of work. The RFC isn't quite as messy as say FTP, but its lower level.
http://www.ietf.org/rfc/rfc4251.txt
User avatar
pythonista
Python Guru
Python Guru
 
Posts: 531
Joined: Wed Jun 25, 2008 6:32 pm
Location: Maryland


Return to Networking

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Dreamlink Web hosting and Traduzioni Rumeno Italiano and ASSP Deluxe for cPanel.