 Hello and welcome today. We're gonna be looking at transferring files from one computer to another through the network on a Linux system Although this could be done on pretty much any operating system, and we're gonna be using SSH for there's many of different options on How you can do this whether you're copying one file multiple files? We're gonna be looking at doing it from the shell. Obviously. We're also gonna be looking at doing it in a GUI interface And we're also gonna be looking at synchronizing stuff so you're not copying files that already exist You know to save yourself time in bandwidth and again We're gonna be using some different tools, but they're all using the SSH service So if you have SSH running on a server you're doing with you that anytime you do networking stuff through SSH That's great, and you can do anything through SSH. You can run GUI applications shell applications You can stream audio. You can share files as we're gonna look at today Anything can be piped through that you can pipe all your web browser traffic through SSH So let's go ahead and get started and again. I'm just gonna do a quick touch on a few different things So right now I'm actually logged into this little folder here that says test I'm on my son's computer, which is the next room over so I'm logged in through SSH here I'm in a directory here called test and there's a file called hello, so we're gonna go we're gonna copy a file there We're gonna copy that file back so I'm gonna switch over to my computer here So I'm gonna folder called tutorials on my computer and here I'm listing out I got a whole bunch of JPEGs which will transfer later right now We're gonna be looking at this alien dot text if I cut that out. It's actually an ASCII image of My son many years ago So it's just a text file, but it's displayed as an image So I want to copy that to my son's computer So I'm going to SCP SCP is great for copying one or many files when you know what you want to copy and just Push it or pull it you know so we're going to SCP And it's just like if you're using copy except for it's over a network So I'm going to say that alien dot text We're going to copy that over to Connor at and do it just like as if you were logging in to An SSH server and then we're gonna say call it now. We can give a full path. We can be like home Connor but if you don't do that anything at this colon if you don't use a forward slash It knows you're looking for the home directory and as we already checked It's a test folder in his home directory. So right here. That's all I have to do. I can say s copy this full file to Connor's home directory in the folder test and We hit enter. I type in my passphrase here And if we switch back over to his computer you can see that that file is there and I can now cat it out So that's on his computer if we want to go the other way around let's go back to my computer. We can do this I Can say Copy as well as copy user Connor. This is his IP address that folder and Hello dot txt where do we want to copy it to I'm gonna say dot which means the current director I'm in but I can give any path on my computer gonna do that again type in my password and It says hello. Also. I want to notice last time I did a video on something like this Someone was telling me that oh, I use security keys for SSH. So I don't have to type in a password I am using a security key. You should use security keys But I do not recommend leaving a blank password to your security keys Everyone has their own opinion on that But if you don't put a password and someone gets on your computer and steals a security key now They have access to all your machines where if you have a password, you know, they'd have to try to brute force it Which is not gonna happen. Uh, so there we go. We copy that over. I can now cat it out on my local machine That's great. And that's great If you know what you want to copy and where you want to copy to but what about You know navigating and then copying and pulling files. Well, you can use SFTP, which is just like FTP only encrypted and again That's not a new service. It's still using SSH. So again, I can go Connor at and For me, let's get to my son's computer or my wife's computer or my daughter's computer or my servers or even my phone I have shortcuts for all of this stuff aliases or even scripts So you don't have to type out all this every time If you create aliases or scripts or functions for your shell, that's the whole point of using the shell You don't have to type a lot if it's something you do regularly I've got type in my password here and now I'm logging computer. I'm in his home directory I can list out the files in his home directory. I can go into that test Folder I can list out the files and if I want to get one of those files. I can pull hello dot txt Sorry, I'm thinking adb. It's get Hello dot txt And I just pulled down be careful because it will override like I just overwritten the hello dot txt in my current directory So be aware that it's not going to warn you if you're overriding something if I want to put a file I can put my alien dot text and you can tab autocomplete So you can transfer files back and forth that way thing is a lot of people don't realize is that you can actually use SFTP in most GUI file managers at least on Linux I can't think of any file manager that doesn't support this so what we do. I like using a PC Man file manager, so I'll just open that up And I'm in my current directory that we're working in and just up here in the URL and again You can do this with Thunar Nautilus Dolphin if those still exist. I've been using PC man FM for a while But whatever you file manager using on Linux if this will probably work SFTP Colon for test forward slash the user name if it's a different user than you 192.168.1.153 is his address It's gonna ask you for a password and you can tell it to remember till you log out Remember forever. I'm just gonna say forget it immediately. So once I close this window directly. It should go away And there we are it brings me right to his computer. We're looking at the root directory So anything Connor has permission to view I can view through here because I'm logged in as Connor I can go to his home directory and go to test I can see those files and at this point I'm gonna make this full screen. I can split the screen and I can go to a folder on my home so Delete this so on the left is Connor's folder on his computer and on the right is mine and I can copy and I can paste I can grab some of these images. I can copy and paste them Takes a moment because they're a little bit bigger and there you go So you have this GUI interface and again you can save that password and then it shows up You can see it right here and I can unmount it if I want so now it's unmounted. That's great You know SFTP that's fine and it shows up in your GUI there But another way that might be a better way is to actually mount the directory through SSH And you can I'm gonna show you how to do that manually But you can actually put it in your fstab files so that it automatically mounts. I don't really I've never really done that I'm also gonna throw out here. My personal opinion is Mounting remote directories. I think is just a bad idea in general I'm not saying there aren't case uses where it's good idea But just remember you mount a remote directory if you accidentally delete something or you get some ransomware Now it can infect that directory and affect everything on that server So I think it's a bad idea I see lots of companies doing it when they don't need to using Windows file shares But this would be the same thing mounting remote directories is not a good idea You're better off synchronizing stuff using sync thing our sink Which we'll talk about next cloud and that way things don't you know if you get something on your machine It has limited access to the stuff on the remote machine rather than just being able to navigate through everything Just a little PSA there So let's talk about mounting a remote directory You will do it through SSH, but you will need to install a tool pseudo apt install SSH FS so SSH file system. I already have it installed and again use it just like all the other commands So I need to make a directory where I'm gonna mount so I'm gonna make a directory called Connor So you can see there it is right there and if I list out right now. There's nothing in there and Now I can SSH FS Connor at 192.168.1.153 again if I just do this it's gonna mount his home directory But let's go ahead and mount his test directory like so and oh I got teleport right amount My Connor directory that I just created again type in my passphrase here And now again if I list you can see the directory there and I can list out what's in that directory Again spelling things right only two ends you can see the files in there and I can CD into it And you can see there and if I open up my file manager again PC man file manager You can see I'm in that directory right now It's showing up here as a mounted directory I still have it mounted as SFTP up here So it's listed in two different places But it shows up just as a regular folder and you and you treat it like a regular folder But again, if you accidentally delete these files, you're deleting them right off the server or if you accidentally change them It's why you're better off really doing a sink in my opinion And again, there's use cases where you don't want to do that and really show is be backing up your servers I'm just giving you a little warning there. I hear about people getting Ran somewhere on the machines and infecting their servers and that should not happen And I think the reason it happens is because people mount remote directories and then everything is just all shared and there's no need for that Anyway, that's just a little little pet peeve of mine But I'm showing you how to do it in case you want to do it lastly, but not leastly So let's see if I should be able to unmount that unmount that it's saying my terminals using it So let's go ahead and move out of that directory and there we go on mounts anyway Now if I move back into Connor, it's showing up in there because it's not mounted anymore let's go ahead and Use our sink real quick. Our sink has a lot of great features. We're gonna go over the very basic uses of our sink here I'm gonna say our sink and Let's say I want to copy all these images to Connors test directory. I would just say Again, it's almost the same as all the other commands. I'm gonna say our sink our sink And I'm gonna say everything in this directory. I need to say like all J pegs I'm gonna say everything in this directory. I want to move over to Connor at Tell it where I want it like this And I'm also just for this. I'm gonna say dash V so we can see the names the files. What's going on so verbose mode so Why use this over? S copy scp Well here it looks so I'm starting to copy. Oh, and I didn't tell it to do it recursively But it's copying all the files there in this directory So you can see it's taking a little bit with the images if I control C to stop that and I run it again Look see how fast it went it sees those fires It's checking those files to see if they've changed, but they haven't changed. It's not going to re-copy them So again, it's going it's going it's going if I stop it halfway and run it again Boom, you see how fast it goes. It's checking those files. No changes on them So it's not moving anything over where if you used scp. It's going to override those files It's going to move them no matter what which is just a waste in many ways So yeah, and again, it told me that it was skipping that directory I'm pretty sure just off the top of my head that R would be recursive. Let's see Got to take my past phrase, right? There we go. I didn't let's go back up. Yeah So it's sent an incremental file list So again, I can stop that if I move back over to Connor's director folder here You can see that file has been copied a lot of the images been copied So copy the folders dash R's recursive So if you want to copy the folder and all the sub folders that will work too and again This is great, especially for copying a lot of files or larger files. You're not going to waste your time If you stop it halfway it will continue where you left off because it's going to check for those changes But even if you copy everything and then you make changes It's only going to make copy over the changes that you've made not everything. So those are a couple of ways to share files On Linux over a network using just SSH, which again, you can there's other options out there The thing is you probably have SSH running if you're doing any type of remote stuff the more Services you have running with ports open. It's just more vulnerability SSH is known. It's secure It's updated anytime. There's there's been a creation in the past It gets fixed right away because it's so widely used so highly recommend it and I thank you for watching Please visit filmsbychrist.com. That's Chris of the K. There's a link in the description and I hope that you have a great day