This is a quick guide for people that do not know you can also transfer files over SSH connection to/from a server with SFTP. SFTP is a protocol that works over SSH/Secure Shell connections. I am using Windows 10 locally and want to transfer files to/from my Linux servers. In the past I have setup plain FTP servers but I do not set them up any longer.
I have setup servers on UpCloud using this guide to setup servers with SSH. I recently blogged about using PHP Storm to transfer files over SFTP but how can I do it outside PHP Storm. I have an older guide on how to do this with the Forklift program on OSX.
Go to https://winscp.net/eng/index.php and download and setup WinSCP.
Ensure you have a working connection to your server over a SSH first.
I connected to my server and compressed a folder ready to transfer over SFTP.
sudo zip -r /17-apr-2019-www.zip /wwwroot/
I now had a 1.8 gigabyte file to download over SFTP.
Setting up a Connection in WinSCP
You will see a window that will allow you to add a server server connection
Add your server name and port for SSH, also ad your SSH username. I wont add a ‘password as I login with SSH keys (not passwords)
Click on Advanced then Advanced to set more options like private keys.
Enter the path to your SSH private Key
It is a good idea to set folders and to remember the last directory used.
Save the connection
Now you will have a quick access shortcut to your server.
Connecting to your Server
I have a passphrase setup for my Private key so I need to enter that on each connection.
I have 2FA hardware one Time Passwords setup at login (read here) and WinSCP asks me for this passphrase. Nice.
Now I can see my remote server as if it was a local drive.
Download a file
I downloaded the backup file created earlier by dragging from the remote server window to my local computer window).
Downloads were not fast (about 1.5MB/s on a 50 megabyte connection.
Enable Right Click Shell Integrations
It is a good idea to enable right shell extensions in Windows Explorer to upload a file via SFTP.
Select Options and Preferences once you connect to a server.
Click Add upload shortcut to Explorer’s ‘Sent To’context menu.
Now when you right click on a file in Windows Explorer you can sent it to a server.
You will be asked by WinSCP what server to connect to, Select it and click Login.
An upload progress bar will appear. When the upload done the WinSCP will disconnect
Editing files in WinSCP
WinSCP is also good at editing files in WinSCP or using your preferred editor.
I hope this guide helps someone. Apologies if you already know this.
v1.0 Inital Post