Putty, PSFTP connection without password prompt

1. you are sending (in general, transferring) files to a server
running SSH
2. you DON'T WANT an interactive shell (e.g. you are doing batch
transfers)
3. you are working on Windows
4. you want a SECURE transfer

In this case, this is the sequence that worked for me:

1. Download puttygen, pageant and pscp from
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
2. Run puttygen to generate a public/private key pair:
2.1 Select SSH1 (RSA) or SSH2 RSA depending on the version of your SSH
server. SSH2 RSA worked fine for me. I think I guessed it by running
SSH Secure Shell (Secure File Transfer Client) downloaded from
http://www.unica.it/ssh/SSHSecureShellClient-3.2.0.exe and looking at
the status information in the bottom right corner.
2.2 Click on Generate
2.3 DO NOT INSERT a key passphrase (otherwise you'll have to
explicitely type it when you connect to the SSH server)
2.4 Click on Save Private Key (I used "mysshkey.ppk")
2.5 DO NOT CLOSE puttygen. Keep it open.
3. Run pageant. It will appear in your icon tray as a computer with a
hat. Double click on it:
3.1 Click on Add Key
3.2 Select the mysshkey.ppk file.
3.3 Click on Close
4. Run putty:
4.1 Login with your username and password
4.2 If it is not already there (check it with "ls -la") create the
".ssh" folder. Cd to it.
4.3 Edit the "authorized_keys" file (or "authorized_keys2"; look for
information, if you can, in the sshd_config file; it could be in
"usr/etc/" or in "/etc/ssh"; otherwise look for it with "find / -name
"sshd_config"; on my server the file was read-protected) If you are a
real Windows user, and have no idea of how to do it, try the
following:
4.3.1 Type "VI authorized_keys" then press ENTER
4.3.2 Type "i" then press ENTER
4.4 Copy the content of the "Public key for pasting in the
authorized_keys file" text box from the puttygen window with Ctrl+C
and paste it in the "authorized_keys" file by right-clicking on the
putty window.
4.5 Save the file and exit (for real Windows users: press ESCAPE and
type ":wq")
4.6 Logout from putty by typing "exit".
5. Now you can upload your files just using the command:

PSCP sourcefilename username@hostname:destfilename"

So, for example, if the file name is "tryit.txt", the user is "john",
the host is "host.microsoft.com" and you want to transfer the file to
the "www" folder as the "tryitonwww.txt" file, the exact command is
the following:

pscp tryit.txt john@host.microsoft.com:www/tryitonwww.txt

http://www.derkeiler.com/Newsgroups/comp.security.ssh/2004-04/0164.html

No comments: