Using PuTTY commandline for downloading file through SSH

I am investigating various options for writing a program that can automate download of files on a SSH server. I need it to automatically log in, navigate to different directories and download all files from there.

However, upon further thinking, it seems to me it may be easier to use PuTTY commandline to download all files from various folders to my own Windows computer.

I currently have a root account which I don't really want. (I am afraid something can go wrong, and I will be to blame.) Could I ask the server administrator to provide me with a limited account only with read privilege - and only to those directories? Would PuTTY still work or does it require something special on the SSH server to work? If so, that would be #1 way for me to solve my client's problem.

2 Answers

WinSCP is a good client for file transfer over SSH, and can work from windows cli or gui.

as for rights, no you don't need root to ssh, and if they reduce your privileges but grant you the required permissions on the files you need, that should work just fine for you. personally I don't allow root login via ssh, but I don't tend to run distros that enable a root account by default.

2

The PuTTY suite of utilities includes pscp which is equivalent to the OpenSSH scp command. You could use it like this:

pscp -pw password :/path/to/folder/* c:\local\folder

This will copy all the remote files in the folder specified to the local folder and would not require anything special on the remote end, aside from permitting the limited user ssh access, and access to the folder.

You would probably want to look into using public/private keys to avoid the need to put the password into your scripts - the second answer to this question shows you how.

Then you would use:

pscp -i /path/to/private.key :/path/to/folder/* c:\local\folder

To do this, the user account would have to have a /home/username/.ssh/authorized_keys file, and the SSH server would have to permit public key authentication.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like