If you're using Linux locally as well as to power your web host, skip to Maintain Unmanaged VPS – Part 10: Copy Site Files between Linux/Linux Computers with the CLI ‘cos the method's different.
If you're after database backup, that's different too, so check this out.
But for Windows/Linux file transfers, you're in the right place, and whether local to remote hosts or vice versa, PSFTP (PuTTY Secure FTP) is a handsome program for transfers .. and the OpenSSH encryption protocol behind it means sensitive data is mixed right up.
To open the programme:-
Up pops a terminal and you see this:-
If you followed VPS Bible – Part 5: Encrypt Data with OpenSSH & Auto-Login with PuTTY, you can use the saved session name we created in that tutorial. That's handy. Just make sure you've got Pageant running. Looking back, in my case, that was guvnr, so I'll stick with that for this. After the command prompt psftp>, I type open guvnr:-
.. and it shouts back:-
Hold On. I didn't do that key authentication thing.
No worries. Using either a hostname or an IP address, do this instead:-
.. or, for the IP ..
It is also kind enough to remind me of my remote working directory:-
Setting PSFTP Working Directories
I can upload or download from there, but for the hell of it I'll cd like this:-
.. and again I get a confirmation of where the deuce I am:-
Remotely, so far so good. Now to cd to the local working directory, using the syntax lcd:-
.. and, as you may have guessed, it confirms my Windows location.
How terribly polite.
Right. Quick breather. And a recap. All we've done is log in, cd‘d to a remote/Linux working directory, and lcd‘d to a local/Windows working directory. Now I'm going to push and shove some stuff between these tunnelled locations.
How to Upload & Download FILES with PSFTP
To upload a file:-
.. up pops confirmation:-
To download a file:-
And to be clear, the put file went to our remote working directory, and the get file came to our local working directory. Easy, init.
One little tip. To change a filename, say, from abc.txt remotely to xyz.txt locally, you'd use:-
.. and the same applies for put operations, and copying folders.
Let's mix it up. What do we want to do? Back up a website, probably. We'll do that, then.
How to Upload & Download FOLDERS with PSFTP
To upload a folder and its content, cd into the local parent directory and, using the recursive command (-r), state the folder name:-
.. it'll confirm the transfer.
To download a folder and its contents, cd into the remote parent directory and ditto above, but using the get operator:-
Really, they should make these things harder. I'm off. I'll leave you with this ..
Useful PSFTP Commands
|!||run a local command|
|bye||finish your SFTP session|
|cd||change remote working directory|
|chmod||change file permissions and modes|
|close||finish SFTP session but do not quit PSFTP|
|del||delete files on the remote server|
|dir||list remote files|
|exit||finish your SFTP session|
|get||download remote file to local machine|
|lcd||change local working directory|
|lpwd||print local working directory|
|ls||list remote files|
|mget||download multiple files at once|
|mkdir||create directories on remote server|
|mput||upload multiple files at once|
|mv||move or rename file(s) on the remote server|
|open||connect to a host|
|put||upload a file from local machine to remote server|
|pwd||print your remote working directory|
|quit||finish your SFTP session|
|reget||continue downloading files|
|ren||move or rename file(s) on the remote server|
|reput||continue uploading files|
|rm||delete files on the remote server|
|rmdir||remove directories on remote server|
Want more info? Don't say I don't give you the earth ..