search
top

How to Use Putty and SCP from Windows to Linux Using Keys

It’s time for another messing of the Linux and Windows world’s. Recently had the task of allowing Windows servers to scp (secure copy) files to a Linux Apache server and automate it. With the help of Putty and private / public keys this is an easy task.

Install PuTTy on the Window server. Download it from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html . Download the Windows installer for everything except PUTTYtel.

Double-click on the executable to start the installation. Accept the defaults for Putty.

Generate Keys
Generate the key on the Linux server for the user. If the private and public keys exist then all that is needed is copy the private key to the Windows server and move on to the next step using puttygen. F not run the following command on the Linux server to generate the 1024 bit private and public key.

ssh-keygen -q -f "serverkey" -t dsa -P "" -N ""

This will generate the keys with no passphrase, you can add a passphrase if you like. Two files will be created.
•    serverkey
•    serverkey.pub

Import the public key into the users authorized_keys file, found in /home/serverkey/.ssh directory with the following command.

$ cat serverkey.pub >> authorized_keys

Setup PuTTy and use in Windows
Next we need to copy the serverkey private key to the Windows server and convert the key to ppk for PuTTy to be able to use the private key we just created.

Copy the private key to the Windows server
Open puttygen


Click Load in the Actions Section
Navigate and select on the key you copied to the system. You may have to change the extension type to all files to find it.


Since we created the key as a SSH-2 DSA on the Linux system we need to click on the SSH-2 DSA in the Parameters section and click Save private key.


Give the file a name including the ppk extension and save it.


Close puttygen

Test
You are now ready to test sending a file. Open a command prompt and type.

c:\Program Files\PUTTY\pscp  -i serverkey.ppk -l serverkey myfile.txt myserver:/tmp

Success! Now you are on your way!

 

One Response to “How to Use Putty and SCP from Windows to Linux Using Keys”

  1. Marc says:

    Tanks for the “How to” it was really helpful !

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top