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.

Download WinSCP

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

Open WinSCP

WinSCP Icon

You will see a window that will allow you to add a server server connection

WinSCP New Connection Screenshot

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)

Screenshot showing a new connection to yourserver.com and port 22

Click on Advanced then Advanced to set more options like private keys.

WinSCP Advanced options menu

Enter the path to your SSH private Key

SSH Private key added

It is a good idea to set folders and to remember the last directory used.

Remember last directory used tick box selected

Save the connection

Save Connection Screenshot.

Now you will have a quick access shortcut to your server.

shortcut to sshuser@yourserver.com

Connecting to your Server

I have a passphrase setup for my Private key so I need to enter that on each connection.

Prompt for private key passphrase

I have 2FA hardware one Time Passwords setup at login (read here) and WinSCP asks me for this passphrase. Nice.

WinSCP asking for my 2FA passphrase

Now I can see my remote server as if it was a local drive.

WinSCP now connected like a local folder

Nice

Download a file

I downloaded the backup file created earlier by dragging from the remote server window to my local computer window).

WinSCP Download Progress Screenshot

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.

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.

Right click Send to menu enabled

You will be asked by WinSCP what server to connect to, Select it and click Login.

Where would you like to upload to.

An upload progress bar will appear. When the upload done the WinSCP will disconnect

When done the WinSCP will disconnect

Nice.

Editing files in WinSCP

WinSCP is also good at editing files in WinSCP or using your preferred editor.

WinSCP editing robots.txt

I hope this guide helps someone. Apologies if you already know this.

v1.0 Inital Post

The post Using the WinSCP Client on Windows to transfer files to and from a Linux server over SFTP appeared first on Code, InfoSec and Server Stuff.