How to download files from remote windows server - python

What would be the best way of downloading / uploading files / directory to / from remote windows server and local windows machine using python scripting language?
Modules I heard of are paramiko and fabric...
Apart from these any other good option/choice?

It depends on the protocol you are using, if the file is big, use UDP, if the file is small use TCP, if the file is small use SSH. You don's necessarily need paramiko or fabric to communicate with another computer, since they are for ssh connections. If you know the protocol, then it is easier to communicate.

Related

Transferring Files via SFTP using Python code on remote server?

I'm trying to automate the process of transferring files from my remote server to my local directory using Python. I know of libraries like pysftp which are popular, but as far as I can tell these libraries require connections to be initiated from the local side (i.e. from a script that lives on the local machine). Is there a way to transfer files from a script that lives on the remote machine instead?
Thanks in advance.

How can I connect to a windows aws virtual machine using python?

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

Copy files from a remote windows virtual machine

I want to do a python script that is able to copy log files from a remote windows 10 virtual machine to the script's machine (Windows) as well as deleting files. A developer in my work place uses WMI with C# to do these kind of stuff but I haven't been able to find anything for Python regarding this topic.
You can use SSH for that.
Paramiko is an awesome library that can run SSH in python: http://www.paramiko.org/

How can I automate remote deployment in python?

I want to automate the remote deployment which currently I am doing manually.
The process includes
Make the tar ball from certain folders
SFTP to the remote server
Rename the old folders
Untar the new tar file
Restart apache
The remote system is on the intranet and has no access to the outside internet
I want to know how can I transfer the file from my python script and then when the transfer is complete then log into ssh and do stuff. I am confused about how can I achieve that. On localhost and I can do all that but how can I do that on a remote host?
For simple&dirty work you can use fabric (This by no means say that you cannot use fabric to build serious product)
For heavy configuration routines, you'd better pick a CMS (e.g., ansible)

Is there an easy way for a python script to bind to all ports on an IP address?

I'm writing a Python script which connects to remote hosts over a (super complicated) SOCKS/SSL tunnel. I am able to establish connections to IPs in a remote intranet on any port.
What I'm hoping to do is set up this python script to use IP addresses in the local loopback range (127.0.x.x) to become (maybe with the help of the hosts file) a 'replica' of the remote systems, and hence enable me to use applications which don't support proxies. The problem is that I don't always know what ports they're trying to connect to. It seems the only way to work this out is to bind sockets to all 65536 ports, which seems a little crazy. So two questions:
Is it crazy? Can I just set up a python list of sockets from 1-65536?
Or is there a better way I should be doing this? Can I monitor connections to an IP somehow and bind the ports just before they're needed?
I want to avoid using too much platform-dependent or non-python code if possible.
EDIT: To clarify, I'm only writing the client here - I have no control over the server. Believe me, if I had control over the server side of it I would not be doing it with SOCKS/SSL/CRAM :)
What about going lower level and interfacing a library designed for network analyzers like pycap?
This way you could detect all connection attempts and find the ports that you need to expose or may be you can just route the packets directly assuming the library in addition to packet detection can also do packet injection (pypcap page says this feature is experimental).
This would IMO make sense in python only for slow applications however...
Pycap seems to be developed for linux, but the core capturing is done by libpcap and for windows there is a similar library winpcap.
Matt,
If using windows your best shot is something like OpenVPN over the tunnel. OpenVPN requires only one TCP port/stream and gives you a pair of virtual interfaces with full connectivity.
[updated]
It may be possible using a TUN/TAP driver on the client side. See this unix version for ideas.

Categories