Easy and Secure File Transferring with WinSCP

0
19164

Easy and Secure File Transferring with WinSCP

Working in a multi-OS environment often requires transferring files between two machines running entirely different operating systems. Even home users who like a range of OSs running on their machine, face the same situation. Although there are numerous techniques available, from using a pen drive to Samba, if you’re looking for easy-to-use solutions, consider WinSCP and VSFTPd.

WinSCP is a decent tool for Windows users, allowing them to share files with their Linux counterparts with ease. So before demonstrating how to use it, first install it on your system.
Obviously, the two systems must be on the same network, with proper IP addresses, etc. In my case, I’m running RHEL 6 on top of Windows 7 using VMware. So here are the steps to connect the Linux in the VM to Windows on the host. If your Windows and Linux systems are different physical machines, VMware users can skip this part.

  • Open your virtual machine and change the Ethernet setting to Custom and select VMnet8(NAT).
  • Assign an IP address to your machine (mine is the C-class 192.168.0.1).
  • Now switch to Windows and open Network and Sharing Center and select Change adapter settings, and here you’ll see a number of adaptors listed. Select the adaptor for VMnet8 (on my system, it’s named Local Area Connection 3). Right-click it and select Properties, and again select Internet Protocol Version 4 (TCP/IPv4). Then click on Properties (see Figure 1).
  • Assign an IP address of the same class as that of our Linux machine (mine is 192.168.0.2).
  • Now the configuration is complete, and you can verify it with ping. You can check the IPs with the ifconfig (Linux) and ipconfig (Windows) commands.

Now it’s time to start WinSCP and see it in action. On the starting screen, enter Host name, User name and Password and click Login (Figure 2). On connecting to a machine for the first time, it’ll generate a warning about the authenticity of the machine you are trying to connect to. Just click Yes, and it’ll connect to the machine. Also copy the key to its cache, so that the next time you log in to the same machine, you don’t see the same warning.

After a successful login, you’ll see a screen divided in two panels, as in Figure 3. The left panel shows the files on the Windows machine, and the right one shows the files on your Linux machine. Now you can copy/move files with simple drag-drops, or using the keyboard shortcuts mentioned at the bottom of the screen. To select multiple files to copy/move, hold the control key while selecting the files/directories.

Securing your FTP server
FTP is widely used for file transfers, and here we’ll deploy an FTP server with OpenSSL support to make file transfers more secure. The steps are:

  • Install the vsftpd package by issuing the yum install vsftpd command.
  • Install openssl by issuing the yum install openssl* command.
  • Change directories: cd /etc/vsftpd and create a self-signed certificate (run openssl req –x509 –nodes –days 365 –newkey rsa:1024 –keyout vinayak.pem –out vinayak.pem). Here, you can use any name for your certificate file, like I’ve used vinayak.pem. Once you issue this command, you’ll be asked to answer a few queries, after which the certificate file will be created.
  • Open /etc/vsftpd/vsftpd.conf file in a text editor and add the following lines at the end of the file:
ssl_enable=YES

allow_anon_ssl=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=YES
ssl_sslv3=YES
rsa_cert_file=/etc/vsftpd/vinayak.pem

Start the FTP service with service vsftpd start and also start the sshd service (service sshd start). Do make sure that your firewall settings are appropriate to let other systems connect to your server for file transferring.

Windows Adapter Setting

Now our server-side configuration is complete, and my FTP server is running on 192.168.0.1. But if I try to access the FTP service with a normal FTP client, it gives an error (Figure 4). We need a secure FTP client, so let’s use sftp, which is installed by the openssh package (but first check if you have it installed, or install it with yum install openssh*). Then access the FTP server with sftp 192.168.0.1 (Figure 5).
So now you can enjoy secure and easy file transfers. That’s all you need for now, and I hope you’ve found this article useful. So till we meet again, keep exploring the amazing world of FOSS.

WinSCP ScreenWinSCP Login

FTP Access ErrorSecure FTP Access

LEAVE A REPLY

Please enter your comment!
Please enter your name here