How to Copy Files Via scp from Linux to Windows

I recently had a project I took on that involved me wanting to do some super secret stuff. The super secret stuff generated logs, and I wanted to move those logs as “near real time” from my super secret computer to my web server. I didn’t want to give ANYTHING access to my super secret server so it had to be able PUSH data. My jobs were running on a Linux box and the web server was a Windows machine with an ssh server on it (Bitvise SSH – trial edition).

In the end it worked! To get there was a pain, so I’m going to try to hit the high points here to minimize the pain for someone else.

The short version is:

1. Install an SSH server on the windows machine (I used bitvise WinSSHD).

2. Make sure your Linux (I was on linux) has scp, ssh, and all those other goodies.

3. On the linux box run: ssh-keygen -t rsa (do this without entering a password/pass phrase)

What that does is generate a public / private key pair that you can use rather than a password when connecting to a remote machine. So it’ll generate a pair of files – one private key and one public. You want to take the public one and IMPORT it into the the ssh server tool on the target machine under the username you want to connect as. Now when you connect you can skip your password!

So here’s me sending a file from a linux machine to a windows machine. I can still this command in a bash script and that’s all there is to it! It takes the file called cmdFileToCopy in the linux directory /home/ja/  and it uploads it to the windows computer located at “myserver.com”  under the username ‘mywindowsuser’ placing it in the folder “C:\temp”.

# scp /home/ja/cmdFileToCopy mywindowsuser@myserver.com:”C:\temp”

Hopefully you find that useful. Free free to commend below and fill in the details. Over time I’ll come back and flesh this out.

Related reading:

http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/

http://kb.mediatemple.net/questions/1626/Using+SSH+keys+on+your+server

http://support.suso.com/supki/SSH_Tutorial_for_Linux

http://knowhowshowhow.blogspot.com/2011/07/ssh-tunnel-failures-in-lion.html

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>