Is there a library that I can use to connect to a remote windows aws machine?
I need just to simulate login and logout.
We most likely need more information about what you are trying to do.
You will probably need to use something like rdpy (to login with the Windows Remote Desktop Protocol) assuming you don't have an ssh server already installed on it. Docs here
Alternatively, you can invoke your rdp client of choice with something like subprocess
Related
I have a Djnago web application on IIS 6 on one server. Is there a way that from this website I call another python script that is on another server in such a way that that script just run itself there?
Calling or Runnig that script in the usual way as internet says, is not working.
I always get the error of os.getcwd() and it also doesn't allow to change that directory.
I just want to run that python script there on that server from this server.
Can anyone help?
Normally, I would recommend using a framework like fabric or winrm if you want to run a python script on another server. Those frameworks use ssh or windows remoting functionality, respectively, to allow a python program to execute other commands (including python scripts) on other systems. If the target machine is a windows machine, be forewarned that you can run into all sorts of UAC issues doing normal operations.
Please I am trying to use linux and I have used it on LiveCD and I really want to use it but the main problem that am having about Linux is that on windows I use an application as a server (ip: 127.0.0.1 port: 8080) to connect to the internet on it and I want to use the same proxy on Linux but I don't know how to do that.
I have tried to extract the Windows Executable file and its a python program (.pyc).
I want to ask if there's a way to pack the files together to be used in Linux so that i will still be connecting through the same proxy again.
I want to download/upload file from remote windows 2008 R2 servers using my python script. The problem is I do not want to install anything extra on my windows server box. I want to achieve this just using my normal login credentials.
Below are the different methods I heard of:
Use paramiko SSH : But to use this we have to install an SSH service on the remote box, which i do not want to do.
Use python wmi module: But I guess it does not have the functionality to download files from the remote servers.
Mount drives on your local box: Also do not want to do this as there will be lot of machines i want to connect to.
Use winscp: I guess it will also require SSH ?
Fabric: Heard of this, not sure what are its prerequisites.
are there any other methods with which i can achieve this?
When in windows do as the windows-users do.
If you can't install additional software on the server, you need to mount the drive, and interact with the remote files like they are local files.
You mention that you have too many remote servers to connect to. Why not pick one drive letter, and reuse it for each server you need to connect to?
With net use you can mount from the command line.
Syntax for net use
net use p: /delete:yes
net use p: \\remote_host\share_name password /user:domain\user
Use Python's subprocess package to run the mount commands. Subprocess tutor.
import subprocess
# Make sure the drive isn't mounted.
try:
subprocess.call('net use p: /delete:yes', shell=True)
except:
# This might fail if the drive wasn't in use.
# As long as the next net use works, we're good.
pass
for host in ("host1", "host2"):
# mount(map) the remote share.
subprocess.call('net use p: \\%s\share_name password /user:domain\user' % host, shell=True)
with open("p:\path\remote-file.txt", "r") as remote_file:
# do stuff
# dismount(map) the drive
subprocess.call('net use p: /delete:yes', shell=True)
(Don't have a windows box and network to test this on.)
Use the win_unc library: http://covenanteyes.github.io/py_win_unc/
This will allow you to do normal modifications to file paths as well as log in as a different user.
i am new to python scripting can someone please assist belo
1.read server, username and password
2.connect unix server
3.change directory and execute command
need some examples for above.
You can use the excellent paramiko package for this. It is an SSH (and SFTP) client library, which will let you easily connect to a Unix server running an ssh service, run commands, transfer files, etc.
You can also use fabric. Fabric is a Python (2.5-2.7) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.
I am writing a script in python, and part of it needs to connect to a remote computer using rdp. Is there a script or an api that I could use to create this function? Also, if there is not, is there a way to package a rdp application along side python and then use a python script to run it? Any help would be much appreciated. Thanks in advance, Nate
If you need an interactive window, use the subprocess module to start your rdesktop.exe (or whatever).
If you need to run some command automatically, you're probably better off forgetting about RDP and using ssh (with passwordless, passphraseless authentication via RSA or similar), psexec (note that some antivirus programs may dislike psexec, not because it's bad, but because it's infrequently been used by malware for bad purposes) or WinRM (this is what you use in PowerShell; it's like ssh or psexec, except it serializes objects on the sender, transmits, and deserializes back to an object on the recipient).
Given a choice among the 3, I'd choose ssh. Cygwin ssh works fine, but there are several other implementations available for Windows.
HTH
As per this GitHub comment, you can try to use libfreerdp via ctypes in Python.
See: FreeRDP library at GitHub which is a free remote desktop protocol library and clients.
Home page: www.freerdp.com
Related: Programmatically manipulating active RDP session.