Python script - SCP on windows

How is it possible to do secure copy using python (windows native install - ActivePython). Unfortunately pexpect module is for unix only and we don't want cygwin locally. I wrote a script that based on pscp.exe win tool - but always stops at first execution becuse of fingerprint host id. and haven't found option to switch this off. the remote hosts are running ssh-server on cygwin (win 2003 servers).

Thanks


Asked by: Maya571 | Posted: 30-11-2021






Answer 1

paramiko is pretty slick. See this question for some more details.

Answered by: Owen132 | Posted: 01-01-2022



Answer 2

I strongly recommend that you use keys rather than passwords. If you use ssh keys properly, you do not need to use expect, as the scp command won't ask for any user input. If you have command line ssh installed, you can make a key like this:

ssh-keygen -t dsa

Then simply follow the instructions provided, and save the key to the default location. If you put a passphrase on it, you'll need to use some sort of ssh agent, either the command line ssh-agent or pagent on windows. You can also create an ssh key with the putty suite's puttygen.

To set up the key for authentication, simply put a copy of id_dsa.pub on the host you want to scp to in the file ~/.ssh/authorized_keys.

Answered by: Lily669 | Posted: 01-01-2022



Answer 3

http://pypi.python.org/pypi/ssh4py

SCP example: http://blog.keyphrene.com/keyphrene/index.php/2008/09/18/13-scp

Answered by: Charlie865 | Posted: 01-01-2022



Answer 4

Twisted Conch supports ssh and sftp.

Answered by: Kimberly572 | Posted: 01-01-2022



Answer 5

How do you expect to provide the authentication data? The easiest way is to create a key, and make sure it is in the server's list of accepted hosts. That way scp will authenticate using the private/public key pair automatically, and "just work".

This is a handy tutorial on how to go about creating and uploading the key. Of course this assumes you have the necessary admin access to the server.

Answered by: Charlie335 | Posted: 01-01-2022



Similar questions

Run Python CGI Script on Windows XP

This exact question has been asked before but I am at my wits end! I've spend 4 hours trying to get a SIMPLE Python CGI script to work on Windows XP but I get errors. Please save my sanity! Python Script register.py #!c:/Python30/python.exe -u print "Content-type: text/html" print "<P>Hello, World!</p>" Script is located in: C:\Program Files\Apache Software Found...


windows - Have python run script at X:00 am

This question already has answers here:


Python script on Windows to access SFTP site

I need to access sftp USER@sfile.WEBSITE.com and get 20110310statement.pdf to a directory $HOME\STATEMENTS at 3am everyday. I don't know how to do it in a script giving username and password and figuring the date string on Windows. I suggest python, but am open to any scripting language. Any pointers ?


python - SMTP Email script doesn't work on Mac but works on Windows

I have some code used to send emails. It works on windows but when I try run it on a mac (with the same user login as on the windows machine), it doesn't send an email or return any errors. Anyone have any experience with this kinda thing, or examples, tips, solutions pls? import smtplib import mimetypes from email import encoders from email.message import Message from email.mime.multipart import M...


Run a python script from the prompt in windows

This question already has answers here:


Run a python script in windows

I have always used a mac to write and run python scripts. However, I have a bunch of files on a PC that I need to run a script on. I have never really used a PC and don't know how to run the script. If I go to the command program on the PC and type in python, nothing happens. How do I find where the python path is in order to get into the python prompt? Also, once I am in the...


macos - How to run Python script on Ubuntu, Windows and MAC

I'm making Python software using wx GUI library but was wondering how to run this script on different OS's. For example, do I need to create executable installation file or bat file on Windows and sh file in Ubuntu? I've got #!/usr/bin/env python at the top of the file and I can seem to run it by actually double clicking it and clicking it on "RUN" on prompt window but I would like it to be more profes...


How to run python script in windows

I need to write a python code which enables me to verify whether the received SSL certificate from a website is valid or not. the code snippet is gonna be executed in windows platform. I've been using Editra to code python recently which is equipped with PyStudio plugin. I got confused if it's a possible idea or not. Does anyone have any idea how to make it work?


windows - How to run a Python script in something other than cmd?

I have written a program. I don't know if it is important how it is written but you can find it here: http://pastebin.com/Z3ZvVPV8 Basically, it asks you to assign values to variables and will perform calculations depending on what variables you chose, and prints the answer. I would like to know how I can make the program run in a window other than cmd (I a...


Need Windows GUI for Python .exe script

I wrote a py .exe script and need to create a GUI for it with a file path input field, a 'cancel' and 'ok' buttons. How can I accomplish it best? Do I need to bind it with any C libraries? I know I could easily create a web based interface but I do not want a web app, I need a .exe app. Please, help!


How do I make a Windows exe from a Python 2.7.3 script?

How do I make an executable from Python 2.7.3 scripts? This seems to work only on 2.6.


Run Python script from cmd in windows

I need to generate features from text. The script I am using below is available online but actually I do not know how to run it because I do not know python at all. I have a text file called (train.txt) contains the following He PRP B-NP reckons VBZ B-VP the DT B-NP current JJ I-NP account NN I-NP deficit NN I-NP will MD B-VP narrow VB I-VP to TO B-PP only RB B-NP # # I-NP 1.8 CD I-NP billion CD I-NP in IN ...


windows - How to embed python code in batch script

In bash, we can: python - << EOF import os print 'hello' EOF to embed python code snippet in bash script. But in Windows batch, this doesn't work - although I can still use python -c but that requires me to collpase my code into one line, which is something I try to avoid. Is there a way to achieve this in batch script? Thanks.


Python 3.3.2 - how to run script on Windows

I have nothing to do with Python, just needed it for one script from Adding a prefix to Bootstrap CSS classes. In "how-to" author instruct to call the script in this way: $python bootstrap_namespace_prefixer.py /path/to/boostrap/dir so in command line I have typed ...


windows - Python script doesn't work with double click

I have a very basic problem, but I cannot find a solution in older answers. When I double click on a python script, I can see a prompt flashing but nothing happens. If I open the same script with IDLE and run it, everything works fine. To be sure the script was not executing propoerly, I made a test script like this: def main(): files = open('test.txt','a') files.write('this is a test') ...


windows - How do I get path to python script, with proper case?

I have a script, B.py, that is imported from another script, say A.py If I import B in A, the __file__ magical constant, has converted some uppercase letters in its path to lowercase. If I run B file directly, the __file__ constant HAS proper case regarding the path. In short this is what happens. The following: telplugins_path = o...


run a python script on windows 7 client from linux using python

I'm new in python so my sincere apologies if this is a dum question. I want to trigger, using python, from a linux server a python script run on an windows 7 client. This script get's the mouse pointer position, makes a screenshot of the desktop and in this screenshot draws an ellipse at the position determine above. I've searched over the internet for a solution but so far I didn't find a method. Is there a metho...


Is it possible to have a Python script run from anywhere else than the Windows shell?

I'm running a script that involves a lot of foreign characters, and the classic cmd line seems to choke on them, which might be related to my Windows setup. It runs fine in IDLE and other IDE's. Is there anyway that I can launch my script automatically from another place (e.g. IDLE) without first having to open another program?


why this a python script works on OSX and not on Windows?

I have a python script which runs perfectly on OSX. After installing python, numpy and matplotlib on windows I cannot understand why the same does not run on windows. Do you have any idea? import numpy from Tkinter import * from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.figure import Figure # main App class class App: def __init__(self, master): # Create...


not able to get float value from python script in C# windows app

I have a python script which reads datatable passed from C#. But when i try to get the value of variable in python script.. it does not fetch value. This issue occurs only for varible of type float. Example when i try to fetch value of "ErrorRate" ( in python script), it returns 0.0 value only.. though the actaule value is 37.55 // C# script // dt is datatable from C# being passed to python var eng...


How to find out if there is data to be read from stdin on Windows in Python?

This code select.select([sys.stdin], [], [], 1.0) does exactly what I want on Linux, but not in Windows. I've used kbhit() in msvcrt before to see if data is available on stdin for reading, but in this case it always returns 0. Additionally msvcrt.getch() returns '\xff' whereas sys.stdin.read(1) returns ...


windows - Using DPAPI with Python?

Is there a way to use the DPAPI (Data Protection Application Programming Interface) on Windows XP with Python? I would prefer to use an existing module if there is one that can do it. Unfortunately I haven't been able to find a way with Google or Stack Overflow. EDIT: I've taken the example code pointed to by "dF" and tweaked it into a standalone library which can be simply used at a high ...


windows - How to set up Python in a web server?

Not exactly about programming, but I need help with this. I'm running a development sever with WampServer. I want to install Python (because I prefer to use Python over PHP), but it seems there isn't an obvious choice. I've read about mod_python and WSGI, and about how the latter is better. However, from what I gathered (I may be wrong) you have to do more low-level stuff with WSGI than with PHP. So I resea...


how to parse windows inf files for python?

please help me. example inf file : ;============================================================================= ; ; Copyright (c) Intel Corporation (2002). ; ; INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE CODE. THIS CODE IS ; LICENSED ON AN "AS IS" BASIS AND INTEL WILL NOT PROVIDE ANY SUPPORT, ; ASSISTANCE, INSTALLATION, TRAINING OR OTHER SERVICES. INTEL DOES NOT ; PROVIDE ANY UPDATES, ENHANCEMENT...


How to setup twill for python 2.6 on Windows?

I have already downloaded twill 0.9. Also, I have installed easy_install for python 2.6. Now I'm stuck with twill installation. Could you help me to settle the problem?


windows - How To: View MFC Doc File in Python

I want to use Python to access MFC document files generically? Can CArchive be used to query a file and view the structure, or does Python, in opening the document, need to know more about the document structure in order to view the contents?


How to set proxy in Windows with Python?

How can I get the current Windows' browser proxy setting, as well as set them to a value? I know I can do this by looking in the registry at Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer, but I'm looking, if it is possible, to do this without messing directly with the registry.


how to run both python 2.6 and 3.0 on the same windows XP box?

What kind of setup do people use to run both python 2.6 and python 3.0 on the same windows machine?


Python 2.6.2, Django 1.0.3, Windows XP, Page not found: /

I'm just starting to learn Python and Django and an unable to get the most basic app working. I've setup Python, added python to the Path environment variable, installed Django using install.py script. I created an app by running the command django-admin.py startproject my_project updated the settings.py file for a database DATABASE_ENGINE = 'sqlite3' DATABASE_NAME...


Using the Python shell in Vi mode on Windows

I know that you can use the Python shell in Vi mode on Unix-like operating systems. For example, I have this line in my ~/.inputrc: set editing-mode vi This lets me use Vi-style editing inside the Python shell. But can this be made to work when using Python on a Windows XP box? I'm using the pre-built Python for Windows downloaded directly from python.org. I'm ...


windows - Create an icon in memory with win32 in python

What's a good way to generate an icon in-memory in python? Right now I'm forced to use pygame to draw the icon, then I save it to disk as an .ico file, and then I load it from disk as an ICO resource... Something like this: if os.path.isfile(self.icon): icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE hicon = win32gui.LoadImage(hinst, ...


windows xp - Process size in XP from Python

I have a python script that can approach the 2 GB process limit under Windows XP. On a machine with 2 GB physical memory, that can pretty much lock up the machine, even if the Python script is running at below normal priority. Is there a way in Python to find out my own process size? Thanks, Gerry


How to find out if there is data to be read from stdin on Windows in Python?

This code select.select([sys.stdin], [], [], 1.0) does exactly what I want on Linux, but not in Windows. I've used kbhit() in msvcrt before to see if data is available on stdin for reading, but in this case it always returns 0. Additionally msvcrt.getch() returns '\xff' whereas sys.stdin.read(1) returns ...


How can I read system information in Python on Windows?

Following from this OS-agnostic question, specifically this response, similar to data available from the likes of /proc/meminfo on Linux, how can I read system information from Windows using Python (including, but...


In the windows python console, how to make Tab = four spaces?

Hello I would like that when I am in the python console tabbing will give me four spaces. Any ideas?


windows xp - Cygwin and Python 2.6

New to python (and programming). What exactly do I need from Cygwin? I'm running python 2.6 on winxp. Can I safely download the complete Cygwin? It just seems like a huge bundle of stuff. Well, I keep running into modules and functionality (i.e. piping output) which suggest downloading various cygwin components. Will cygwin change or modify any other os functionality or have any other side effects?


windows - Using DPAPI with Python?

Is there a way to use the DPAPI (Data Protection Application Programming Interface) on Windows XP with Python? I would prefer to use an existing module if there is one that can do it. Unfortunately I haven't been able to find a way with Google or Stack Overflow. EDIT: I've taken the example code pointed to by "dF" and tweaked it into a standalone library which can be simply used at a high ...


windows - How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage?

I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities. I'd like to create a web page served from one of my systems that would merely present a few buttons which would allow me to initiate these scripts remotely. The problem is that I do...


How do I create a windows service with Python


windows - Example of how to use msilib to create a .msi file from a python module

Can anyone give me an example of how to use python's msilib standard library module to create a msi file from a custom python module? For example, let's say I have a custom module called cool.py with the following code class Cool(object): def print_cool(self): print "cool" and I wa...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top