How to use SFTP Commands to Copy Files to/from a Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is tony teaches tech i'm tony and in this video i'm going to show you how to use the sftp command to copy files to and from a remote server and if you're not familiar sftp stands for secure ftp and if you're not familiar ftp stands for file transfer protocol so we got secure file transfer protocol and all that means is that when you're copying these files when you're uploading them or downloading them from your remote server everything's going to be encrypted so from the time it leaves the remote server to the time it gets to your local computer and vice versa all of the data will be encrypted so nobody can read it in plain text like a bad actor a hacker or anything like that so um we're basically going to copy a an entire static website up to a remote ftp server using the sftp command on the command line this will work for any operating system windows mac linux and if that is something you guys want to learn how to do let's go ahead and get on into the tutorial here okay so i'm on a mac um we're going to use terminal if you're on linux you'll also use terminal window to issue the ftp commands specifically sftp commands i might mix up the two in this video but i anytime i say ftp i always mean sftp and if you're on windows you want to use the command prompt it's a windows command line so you can access that by going to your start menu search and then typing in cmd hit enter and you'll get a command prompt where sftp should be installed um okay and then we have our website here that we're going to be working with today we'll get into this in a little bit but i just want to know let you guys know that that exists the first thing you want to do actually is to log into the sftp server and we can do that by typing the command sftp the username in my case it's lemonade and i'm gonna assume that you have uh ftp credentials um and then the domain name is tony florida dot me i'm gonna hit enter it's gonna prompt me for my password i'll type that in i think i got that right nope i got it wrong all right second time's a charm so now we are connected we're authenticated with the sftp server as we can see here all of our commands will be prefixed with sftp at this point forward and in case you're new to this whole thing like i said i'm assuming you have access to an ftp server in the background here i have a graphical user interface at gui for my ftp server which is hosted at dreamhost.com it's a hosting company and the domain name the the server that we're working with is tonyflorida.me which at this point you can't there's not much in this directory here we just have the couple fave icons and if we go to the actual website tonyflorida.me you'll see that there is not a website but by the end of this tutorial we're going to take the website from our local computer here and move that up to the remote server so we can actually see an actual website being hosted at tonyflorida.me okay so let's go ahead and get into this um we can issue commands there's just you just got to keep in mind that there's two file systems here that we're working with our local file system and our remote file system so um i'll explain the difference here so if we just type in ls if you're familiar with these type of commands we'll list out the directory content so this is on the remote server so um and if you're not if you're familiar as well cd is the change directory command so we can go into the tony florida.me folder and do another ls in here and you'll see those two fave icons that we just looked at now that all those commands were issued on the remote server if we want to look at our local computer then we pretty much have to prefix those commands with an l for local so basically what i mean what that means is l l s for local list and this is what we're looking at locally on our current directory and we can do lpwd to see where we're actually at on our local computer print working directory and then we can do an lcd to go into our desktop for example and then lls we'll see the websites directory and lcd local change directory to go into the website directory and then lls we'll see our assets elements.html generic.html images in index.html which corresponds directly to what we're seeing over here in the website's directory so the goal here like i said is to copy all of these files up to the remote ftp server and that's actually a very simple thing to do but before we do that i want to show you how to first download files from the remote server so let's do a question mark here these are all the commands that we can execute we saw a couple of these lls lcd regular ls in order to get the files from the remote server it's actually pretty straightforward you can use the get command so let's type in get and because we have those let's remind you we have two files up here these two fave icon files if you want to get both of those files we can use we can either type favicon.gif and then execute that and then favicon.ico get that but we know both of them um exist up there at this point we can actually do a asterix which is like a wild card so that's going to download both of those files at once so hit enter and it's getting those two files it says it here in the output and you'll see over here that those two files now exist locally on our current computer in our current working directory okay so we don't really need those i just wanted to demonstrate downloading files so let's go ahead and get rid of them now like i promised let's uh show you how to upload files so in order to do that we can use the put command which is the opposite of get so put is going to upload files to the remote server and because we're working with directories okay so we have all of these files in the root of our website's directory but then we have folders and then inside folders we have more sub directories and then we finally have files so in order to recursively copy everything we want to give it the dash r flag and you can see that here uh here dash r so that's going to be recursive so we can do put dash r everything in our current working directory and let me just remind you this is our current working directory so we're going to do put dash r everything in our current working directory and that's going to upload everything to the remote server hit enter and it's starting to do that so you can see our assets it went into the javascript directory got all those javascript files it's getting our images and finally the index.html file so that was pretty quick it didn't take that long at this point if we do an ls for the remote listing of what's on the remote ftp server we now see that in addition to the fav icons we see everything that was local is now remote so let's confirm that in the gui here let's refresh this and we should see assets images all the html files and at this point let's see if we can refresh the page and see our actual website here and we do so this is everything that was contained in the static website we got all of our images all of our design our layout all the resources css javascript have been copied up and it is making this working website so um hopefully this gives you guys a better idea about how to use the sftp command to copy files to and from a remote server if you have any questions let me know in the comments below i'll do my best to help you out i have some other videos about how to transfer files um to remote servers we can use ssc scp secure copy and stuff like that so um check out some videos over here and thank you guys for watching please subscribe for more videos like this from me in the future and if you do i'll see you in the next one you
Info
Channel: Tony Teaches Tech
Views: 131,907
Rating: undefined out of 5
Keywords: sftp, sftp commands, sftp windows, linux sftp command, sftp command line, sftp command line windows, sftp put command, sftp command line linux, sftp get command, sftp command in unix, sftp command with password example, sftp commands windows, how to connect sftp server from windows command prompt, sftp in windows command prompt, how to sftp from windows command line, sftp using command line windows, sftp via command line windows, sftp windows command prompt, scp command
Id: 22lBJIfO9qQ
Channel Id: undefined
Length: 8min 28sec (508 seconds)
Published: Fri Apr 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.