File Transfer Between Local and Remote Computers

Transcript

Note that the commands shown below are typed in with no Enter in the middle even if shown continuing on a second line because the browser window isn't wide enough.

Mac

File transfer can use the scp command in a Terminal Window on your Mac. This software comes with OS X.

You need to have a second terminal window open, in addition to the terminal window accessing the remote VCL Linux system, as was the case in the previous exercises. This one is running on your Mac. (It's started from Applications/Utilities.)

You can transfer a file in either direction using the scp command, using your local Terminal window, giving the "from" file first and the "to" second. So to transfer a file to the remote computer from your local home directory (indicated by the ~ symbol)

H:~ Henry$ scp file-name myid@152.46.18.165:.
where 152.46.18.165 is the IP address of your Glide image reservation and "file-name" is the name of your file on your local computer to be copied to the remote computer. The "." after the ":" says to keep the file-name the same. You will then receive a password request from the remote computer - use the same password you used to login. Use your window to the remote computer to see that the file was received.

Similarly the command

H:~ Henry$ scp myid@152.46.18.165:file-name .
transfers the remote file back into your local directory. Don't forget the space after the file name, and then the following "." says it goes into the directory in which you are working with the same name. As before, you will get a password request.

 

 

 

 

Windows
WinSCP is a free software package for transferring files. Check if it has already been installed on your local machine. If it hasn't, it needs to be downloaded to your local machine - so you likely will need to have administrator privilege.

To use WinSCP when you are have the Glide command window open via PuTTY, you need to start WinSCP. Use the File Protocol drop down menu to choose SCP, and then login. You'll then have a window showing both your local and remote directories. You can change directories by clicking on the line showing the current directory or double clicking the (sub)directory shown.

Then you just click and drag files from one computer to the other. But there is a small problem. Windows and Linux use a slightly different way to designate ending a line and starting a new line in a text file ("text" includes numerical data). So if you move a data file from Windows to the remote Linux computer, you'll need to convert the file in the remote computer to use the Linux standard. That's very easy using the dos2unix command.*

[hes@vm18-165 ~]$ dos2unix file-name
dos2unix: converting file file-name to Unix format ...

Now you're ready to use the data file on the remote Linux computer.

To move text files from the remote Linux computer back to your local Windows computer.
First - convert to Windows* line endings via

[hes@vm18-165 ~]$ unix2dos file-name
unix2dos: converting file file-name to DOS format ...

and then use WinSCP as above to click/drag the file to your Local computer.

*If you're curious about the use of "unix" vs "Linux" - "unix" was the predecessor of Linux, and the name of this command wasn't changed. Also the original Microsoft Operating System was called "DOS" not Windows.

[hes@vm18-165 ~]$ sftp myid@152.46.18.165
The sftp command is similar to scp, but is more efficient when more than one or two file transfers are to be done. It is included in the MacOS and in WinSCP - but read about the file format in the Windows section above. When transfering several/many files, perhaps using multiple directories - it certainly can be done with scp, but with a lot of typing and multiples authentications. The sftp command only takes one authentication (when you login to do the transfers), allows changing directories and more. This good short writeup covers the basics. Note: use your server IP address and directories, not those given in the example. Also other software can provide sftp capabilities, e.g. FileZilla.

For a lot more about transfering files including larger scale techniques (see Globus on that page for really large amounts of data.) But for most learning by trying, probably including class assignments, the scp transfer method described above should be adequate.


Return to Glide main page
Copyright 2019, 2020, 2021 by Henry E. Schaffer. Comments and suggestions are welcome, and should go to hes@ncsu.edu
Licensed under the Creative Commons Attribution-NonCommercial 4.0 International Public License https://creativecommons.org/licenses/by-nc/4.0/legalcode
Last updated 2/22/2021