File Transfer (scp & sftp)
Copy files between your computer and the CSCD 240 lab server
You will regularly need to move files between your local machine and the server. Two tools do this: scp (copy) and sftp (interactive file browser). Both are built into macOS, Windows 10+, and Linux.
Make sure your GlobalProtect VPN is connected before using either tool.
scp – Copy a Single File
scp works like cp, but across machines. The syntax is:
scp SOURCE DESTINATION
One side is local, the other is username@host:path.
Upload a file to the server
scp myfile.c YOUR_USERNAME@TBD.ewu.edu:~/
This copies myfile.c from your current directory to your home directory (~/) on the server.
Download a file from the server
scp YOUR_USERNAME@TBD.ewu.edu:~/lab1/output.txt .
This copies output.txt from ~/lab1/ on the server to your current local directory (.).
Upload an entire directory
Add -r for recursive:
scp -r my-project/ YOUR_USERNAME@TBD.ewu.edu:~/
Download an entire directory
scp -r YOUR_USERNAME@TBD.ewu.edu:~/lab1/ .
sftp – Interactive File Browser
sftp opens an interactive session where you can browse, upload, and download files with commands similar to what you already know.
Start a session
sftp YOUR_USERNAME@TBD.ewu.edu
Enter your password. You will see:
sftp>
Useful sftp commands
| Command | What It Does |
|---|---|
ls |
List files on the server |
lls |
List files on your local machine |
cd lab1 |
Change directory on the server |
lcd Downloads |
Change directory on your local machine |
put myfile.c |
Upload a file from local to server |
get output.txt |
Download a file from server to local |
put -r my-project |
Upload a directory |
get -r lab1 |
Download a directory |
pwd |
Print server working directory |
lpwd |
Print local working directory |
exit |
Close the session |
Example session
sftp> cd lab1
sftp> ls
Makefile main.c output.txt
sftp> get output.txt
Fetching /home/jdoner42/lab1/output.txt to output.txt
sftp> lcd Desktop
sftp> put fixed_main.c
Uploading fixed_main.c to /home/jdoner42/lab1/fixed_main.c
sftp> exit
Which Should I Use?
| Use Case | Tool |
|---|---|
| Copy one file quickly | scp |
| Copy a whole directory | scp -r |
| Browse around and pick files | sftp |
| Script/automate transfers | scp |
Both tools use the same SSH connection, so if ssh works, these will too.
Troubleshooting
| Problem | Fix |
|---|---|
Connection timed out |
Connect to GlobalProtect first |
No such file or directory |
Check the remote path – use sftp to browse |
Permission denied |
Check your username and password |
| Transfer seems stuck | Large files take time – check your network connection |