5

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 2

12

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
  • Thanks for your answer. I have upvoted it for now. More than anything I need commandline though. But I will check out WinSCP :)
    – Tom
    Mar 13, 2013 at 13:33
  • winscp can be used via cli, so its just a matter of taste in clients. Mar 13, 2013 at 17:48
8

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

pscp -pw password [email protected]:/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 [email protected]:/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
  • This appears to be an ideal solution. I will leave the quesion open for some time to receive more answers. (But I suspect I will be marking this as the answer.) I upvoted your answer for now :)
    – Tom
    Mar 13, 2013 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .