Transferring Files Using SFTP and SCP ============================================================================= Written by jebug29 ``` Created: 24 May 2020 Modified: 24 May 2020 ``` SFTP (secure file transfer protocol) and SCP (secure copy protocol) are file transfer protocols intended to allow users to send and receive files over SSH. Knowing how to use them is an invaluable skill for any user who regularly connects to remote shell accounts over the internet. Instead of being split up by operating system like the Connection Guide[0], this guide will be split up by GUI and commandline. **READ Notes on Quotas and Banned Content BEFORE PROCEEDING.** Methods ----------------------------------------------------------------------------- * GUI (Filezilla) * Command Line (SCP and SFTP) Notes on Quotas and Banned Content ----------------------------------------------------------------------------- > User quotas are in place for a reason, but they don't stop users from *attempting* to upload files past their quota. If you are abusing Sector Disk's bandwidth by attempting to upload or download extremely large or large amounts of files, you will be given one warning before you are banned. > > NSFW materials are NOT allowed on Sector Disk and neither is pirated content. If you are caught placing illegal or inappropriate content on Sector Disk, you will be banned immediately and all of your content permanently removed. > > Banned users will not be refunded for any reason. GUI Method ----------------------------------------------------------------------------- * You will need an SFTP or SCP Client. I am using Filezilla[1] for this guide. Open Filezilla and type in the following information to the top bar: ``` Server: sftp://sectordisk.pw Username: [your Sector Disk username] Password: [your password] Port: 22 ``` Press `[ Enter ]` or the 'Connect' button and Filezilla will connect you to your HOME directory on Sector Disk (likely `/home/yourusername`). From there, you should be able to drag files into/out of the file listing of your home directory. !Filezilla Window[2] !Drag and Drop[3] If you would like to add these settings to Filezilla permanently, you can do so using the built-in Site Manager, accessible at `File -> Site Manager` or via the keyboard shortcut (`[ Ctrl-S ]` on Windows). __Note that I do NOT recommend storing your Sector Disk password in Filezilla, as Filezilla DOES NOT ENCRYPT STORED PASSWORDS BY DEFAULT.__ There other are guides available on how to enable stored password encryption out there on the web, but I offer no guarantees. (Filezilla really isn't even the best client, but it *is* user-friendly and multiplatform, which is why I'm using it for this guide). !Filezilla Site Manager[4] Command Line Methods ----------------------------------------------------------------------------- >This assumes that you have OpenSSH installed. Windows users *may* have this installed if they're on Windows 10, but they may not. Continue with that in mind. There are two options here: SCP and SFTP. SFTP is a bit more user-friendly of a tool and allows you to sift through directories and such, where SCP is for more advanced users who know exactly where their files are and *exactly* what they want to get from or put onto a server. Although technically for more advanced users, SCP is actually easier and lighter to use for small file transfers. Both, when used correctly, should achieve the same desired effect. SCP (Secure Copy Protocol) ----------------------------------------------------------------------------- To upload a file to your home directory using SCP, simply use the `scp` command as follows: (Note that if your filename has spaces, you should enclose it in "quotes"). ``` scp source_filename user@sectordisk.pw ``` If you want to upload a file using a different filename from the source filename, simply add a colon and the destination filename to the server. ``` scp source_filename user@sectordisk.pw:dest_filename ``` If you want to retrieve a file from the server, simply switch around your parameters so that the server is first. ``` scp user@sectordisk.pw:filetoget output_filename ``` SFTP (Secure File Transfer Protocol) ----------------------------------------------------------------------------- ``` Quick SFTP Command Reference: put Put file from local machine onto the server get Get file from server onto the local machine cd Change directory on the server ls List files in directory on the server lcd Change directory on the local machine lls List files in directory on the local machine quit Close the connection ``` Connecting to a server via SFTP is almost exactly the same as connecting to a server via SSH. Simply use the command `sftp user@sectordisk.pw` and enter your password and you will be connected. !SFTP Connected[5] At the prompt you are able to put in various commands to allow you to browse through files and upload/download files. For example, if I want to see what files are in the directory I am in, I can use the `ls` command, just like at the shell. If I want to download one of those files to my local machine, I can use the `get` command. I can change directories using the `cd` command. !SFTP get, ls, cd[6] If I want to get a list of the files on my local machine, I can run the command `lls`. If I want to change directories, I can do `lcd`. !SFTP lls, lcd[7] If I want to place a file onto the server, I can use the `put` command. !SFTP put[8] >Note that if you're `put`ting or `get`ting to make sure you don't overwrite files that already exist! SFTP won't warn you! To quit sftp, simply enter the `quit` command. If something goes wrong and you can't enter the `quit` command, use `[ Control-C ]` to force the program to close. [0] gopher://sectordisk.pw/0/tutorials/connection-guide.md [1] https://filezilla-project.org/ [2] gopher://sectordisk.pw/I/tutorials/file-transfer/sd-filezilla-1.png [3] gopher://sectordisk.pw/I/tutorials/file-transfer/sd-filezilla-2.png [4] gopher://sectordisk.pw/I/tutorials/file-transfer/sd-filezilla-3.png [5] gopher://sectordisk.pw/I/tutorials/file-transfer/sftp-1.png [6] gopher://sectordisk.pw/I/tutorials/file-transfer/sftp-3.png [7] gopher://sectordisk.pw/I/tutorials/file-transfer/sftp-4.png [8] gopher://sectordisk.pw/I/tutorials/file-transfer/sftp-5.png