hey guys welcome to lgh project my name is salman francis and in this video we are going to take a look at SFTP or secure file transfer protocol smtp is basically ssh file transfer protocol and it transferred data securely by using encryption SFTP works as a subsystem of ssh and shares the same port what ssh is configured for which is by default port 22 please note that SFTP is not FTP protocol rather it’s a different protocol okay don’t confuse it it’s secure FTP protocol it’s not a file transfer protocol what we use it’s basically a subsystem of ssh okay so it simply uses an ftp style of interaction between a client NN sshd server okay so to connect to a remote system where SFTP we use SFTP command followed by the user and at IP address or domain name and then it will give us a prompt of SFTP to list the content use the LS command to change to the directory we use CD command or CH dir command like simple linux commands to list the current working directory use PWD and to make a direct we used make dir command followed by the directory name of your choice okay to copy files from remote machine to current machine where your or I will be connected i will use put command and to copy files from the machine or SFTP connected machine tool the remote machine i will use the cat command okay then please understand that what files you can upload and download you can just press the tab key fall like put type the command put and then press the tab key and then you will understand what files you can upload and when you will type the get command and press the tab key you can see that what files you can download so basically put is to upload and get is to download okay dash are whenever is used its will be recursive means that you can copy the directory and the contract home directory okay and there are some examples and if you guys want let me know just type that in the comment section and then i can give you the link for this slide so you can download the slide also so guys let’s take a look at the demo so for this purpose we are going to use two machines let me minimize this and you can see with the IP address IPA that this is 192 168 1 dot 10 and the other machine with the IP address a IPA is one dot 50 so we have two machines 1 dot 10 and 1 dot 50 so that’s clear okay now to connect what I’m going to do is I’m going to connect from one or ten 250 and for that purpose I make use SFTP command followed by the user root and connecting with user root you can connect with any user and whenever you are going to connect with this user you are going to go into his or land in his home directory so how we can prove that let let’s let’s list the content and you can see that it’s showing me the content over here okay LS and you can see the same directories here so this means that right now we are in roots home directory okay so let’s say if you connect with the user test you are going to land in his home directory or the tests home directory okay perfect so now let’s let me show you what we can do with this SMTP protocol so let’s say I have this I want to put a file okay or first let’s do some small things let’s say make directly mkdir is used to make the directory and i’m going to call it last drop okay list the content you can see that this last group should be created I cannot see it here yeah here last group is created and over here you can see that at the moment it does not exist but let’s LS and now we can see that it’s created okay good now what I’m going to use they do is I’m going to go into this last group directory and you can see at the moment there is nothing in it so what I’m going to you do is I am going to upload a file so as you know that to upload a file we use the put command and press the tab key and you can see that the list of files what you can upload so I’m going to upload this test dot txt to this last crop okay let’s check where I am right now currently I am in route so CD into last group and now i’m in lash grip so to upload a file put and then the tab key or just type the file name press ENTER and here you can see it’s hundred percent uploaded list and it’s available there let’s prove it LS and now you can see the test txt exists of your perfect now let’s remove this file RM is used to remove the file test or txt removing file going back to this directory LS and you can see that the directory is the file is gone okay let’s see let’s say you want to let’s say you want to download some files I am going to create here in the last group of file let’s say touch server batch 192 dot one sixty eight dot one dot 50 dot txt okay and now going to one dot 10 we can see that we don’t have such file so I want to download this file what I can do is get get and now press the tab key and at the moment it’s not giving me anything because I am in last group okay it should actually tell us yeah it should give me the file anyway get let’s and type the file name server and press tab and it it has completed it by itself enter and it’s fetching and now just a minute a new version has been released by virtual box okay fetching and let’s see if it’s downloaded LS and perfect we can see that server 192 168 1 dot 52 txt is now available on my one dot n machine good okay now back let’s minimize this now again how we can basically let me go out of this unless the code okay now how I can upload the directory with its content for example let me again go to this machine you can see it’s 110 clear the screen list so i have this directory called last group here CD into this and we have some sub directories and files in it okay now very important thing to know sft works in such a way that whenever you are going to upload the file you should have the same directory name in the remote system also what what do i mean by that for example let’s say i want to upload this directly last group with the content of this directory I should have the same directory name last group or any other directory name but it should be same in my remote machine also otherwise that’s going to give you some error so let’s try to upload the files at the moment you can see that i don’t like i have only one file error and i’m going to remove it okay clear now I don’t have any content here now i’m going to put with dash are our is recursive to put all the content the directory annex content and what last group press ENTER and you can see that now it has uploaded the files okay and everything in it LS and you can see that the content is available now and you can even go into the directories and list the content of everything is there so let’s see what will happen if this directory does not exist so I’m going to just RM dash RF tasker full directory and all the content clear and this time let’s try to upload it again and you can see that it’s giving me this error unable to canonicalize the path so that’s the biggest error let’s do it again mkdir even let’s say it’s I’m in / route okay so mkdir last group this time because the directory has been created this time if I use the same command little work so this is very important thing to know and understand last group and everything is back okay now but this thing has no effect on the downloading thing for example let’s say let me go out last group I am deleting this and we have this SFTP d directory here on this server and let’s go to our one or ten machine and delete that because i think i have this no i don’t have it ok you can see that there’s no such kind of such directly SFTP d ok so now let’s download this this directly and the content which is this file in this directory to r 1 dot 10 machine here so to do that we use the get command followed by our press tab key and SF ok this and you can see that it never gave me an error and let’s tell us the content and now this directory is available here and you can check with IPA to prove that this is one dot 10 machine and this one is one dot 50 so perfect we have proved our point that in order to upload you should have the same directory name as in the remote machine as in the local machine and to download you don’t need anything fancy anyway guys so this is the end of this video and I hope you guys have enjoyed it so please don’t forget to subscribe to our YouTube channel and follow us on Twitter it’s at linux king 77 you can always join our facebook group it’s and like our facebook page it’s facebook.com forward slash the next king 77 and our group name is lzh project on facebook so thank you for watching and goodbye