Use SSH and SCP to Manage Lots of Linux Machines

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
greetings and salutations and thank you for clicking on this video today I want to talk about administering your Linux network of computers now for those of you who only have one Linux computer because you've just started out you haven't figured out yet that Linux computers are sort of kind of like potato chips you can't just have one because hey you know somebody might give you a machine or you might see one somewhere use that you want to pick up and the first thing that you're going to do is load Linux on it right because Linux is free to download free to install and pretty soon you realize that you can have as many computers as you want and the next thing you know you got a whole house full of computers in my case I've got three computers one of them is a desktop one of them is a really kind of snazzy laptop that's good for watching videos and playing games on that's what my kids use and then I have my kind of junker HP laptop that I usually do these videos from you guys have seen that so I need to take care of all these machines make sure they're all up-to-date and I could go around from one machine to the next and kick who's ever using them you know the machine just tell them to go away but I don't do that I use some tools to take care of this and the main tool that I want to talk about today is SSH because SSH is awesome I did a video not too long ago about getting started with SSH and since I posted that video I have used it pretty much every day I don't know what was wrong with me I knew about SSH but for a while I just didn't use it I didn't have it set up on my systems and now that I'm using it I'm going wow how did I ever live without it so I'm going to show you some of the basic things on how SSH works now this video is not a tutorial of how to set this stuff up I am NOT going to show you all of the options and all of the things that you can do this is a demonstration of the technology and I strongly encourage you to do some research and find out about some of the things I'm going to talk about here and some of the tips and tricks on your own mr. Google is your friend you can look up lots of great tutorials on how to install and set up SSH and we'll talk a bit more about that as we roll along so what is SSH well that is the secure shell and it is a way that you can log into a computer over a network so let's do it right now so command would be SSH if the machine has an account that is exactly the same as the account that you're logging in from in other words you have an account on that machine you don't need to tell it what account it is all you need to do is just put in the IP address or the host name of that machine depending on how your network is set up mine is set up to use IP addresses so the first machine that we're gonna log into is the great big Dell desktop that's in the back so we're now logged in and as you can see it gives me a message to let me know that I'm logged in what machine it is it's telling me that all of the packages are updated so this is pretty cool now I didn't have to put in a password because I have set SSH up with key authentication this is where you generate unique keys and you have one on the local machine that you're getting into the machine that you're getting into a remote machine from you have these keys and they talk to each other and that way there's no passwords involved that's safer if somebody is going to be sniffing your network and trying to break into your systems using SSH if you have password authentication setup then you might end up with a situation where they can brute force their way in keys are very hard to get into so I would suggest at some point down the road that you look into setting that up for yourself so that's makes it easier to for me because if I'm getting into one of my local network machines then it's no big deal okay so we're into this machine what can we do here well we can do anything in this machine that we would do at a terminal so I know it's up-to-date but we'll check anyway so I will type in sudo apt update give it my password for that now because that's a administrative command and now it's gone out to the internet and it checks for updates and I know this machine is not going to prompt me to install an update because it just did that a little while ago and it says all packages are up to date so we're good to go there if I needed to install updates I could do that as well now I use a terminal called Terminator and Terminator allows me to split the terminal up and now over here I can issue this command to another machine and we just logged into my Dell laptop now I'm using key authentication here so you know that's why it logged right in with no big deal and you'll notice here that we have a little forward here it says why I'm going to show you what that does next because SSH is terminal based but every now and again you might want to launch an application for one reason or the other on the other end and you don't need a full remote desktop where you see the entire desktop and get mouse and cursor and you're trying to send all that information no you just can use the X server to send the commands from the machine you're logging into to the machine that you're in to draw a picture of whatever's on the screen to do that what we're gonna have to do here is we're going to have to log out just type exit and now you see it tells me that the connection is closed and then we're gonna log back in and this time I'm going to add the flag and this is going to enable X forwarding on this machine if I would use a dash X it would not only enable the X forwarding but it would encrypt those X commands so that other people couldn't sniff what was going on and see what we were looking at and what I'm gonna do here is just a scoping up something simple I mean like I said this works best for really simple applications opening up a web browser with X not such a good idea you might want to set up a remote desktop if you want to do something like that but for simple applications it works nice so let's open up the matei control center I typed that right yep so here comes so now what's going on here is that on the other end of the machine it opened up the application but instead of displaying it on the screen it is taking the commands from the X server sending them through the network and the X client on the machine that I'm sitting at is drawing the picture for us pretty cool so I can open this up and check out settings and do all kinds of stuff with that so that's exporting I wanted to least touch on that I don't use that very often but it is there so this is great I mean I can get into these machines and run all kinds of commands I can see what the machine is doing I'll put a CH top in here let me go ahead and exit out of this machine because I don't need that right now we need a full terminal yeah sometimes gonna use X for wording it kind of hangs up like that but ctrl C will get you out so exit again and now I've got a full screen now I'm looking to see what the machine is doing and this is the laptop computer that's on the other side of the house right now so I can jump in here and check things out do all kinds of things one of the things that you can do which is really useful is to learn how to use the user's command before you do any of this stuff so if you jump into a machine and you're not in that room and you don't know if somebody else is using it users will tell you no that's not what I wanted tight users thank you right now I'm the only person in that machine if somebody else was in that machine then we would definitely see something else there so I'm gonna go ahead and get out of that I think Cindy's logged in to the one in the back so let's login to that machine real quick once again and now if I type users yeah you see that she's running on that machine so before you do anything like restart the computer or something like that might be a good idea check and see if there are other users on that machine at the same time alright so that's the basics of SSH and there's there's a lot to SSH and I do you know encourage you to go look and find out more about it the next thing I want to show you is how to copy files across the network because this is really useful I mean really useful so to do that today I have a virtual machine set up and I do have the SSH server installed here but it's not fully configured so I'll have to use password access to get in that's okay for a virtual machine I don't mind but it will serve its purpose here so all Linux computers have the SSH client installed so pretty much any machine that you sit down in front of is going to be able to get into any other machine that's running the server so I can jump into an SSH session with another machine very easily from a VM but I've actually put the server up here at that's running as well but I need to know the IP address of this machine which is really important because I don't have it set up to do host names on the network that sort of thing some networks have that set up some don't I like to use IP addresses I have my router set up to give IP leases to certain devices it's not static IPS which are take a little longer to set up and I kind of change machines around a lot so it I just use IP leases for those of you who know what all that's all about so anyway let's figure out what the IP address is on this machine okay I got it right it only took three tries okay so the current IP address on this machine is 192.168.0 two-three and we're gonna need to know that because i want to send a file to this machine using ssh and we're gonna do that using a command called SCP now you may be familiar with samba where you can share files you may be familiar with setting up a network area storage device I've got one of those set up but I rarely ever use it this is another way to transfer files back and forth quite easily from machine to machine and this is my go-to method I no longer run a Samba network and I don't even have any storage plugged into my network area storage device simply because of the fact that this is just so easy to transfer stuff back and forth so what I want to do is I am going to let's see here I'm gonna switch directories just to make this easier and we are going to go to desktop and we're gonna go to work which is a directory that lives on the desktop alright there we are we're gonna list the storage and you see I have a file in here called VM config so what I want to do is move that file to my VM because that's where I have all my little cheat files that allow me to set up a VM real quick so what I'm gonna do is I'm going to use the SCP command which is secure copy over the network and then I am going to type in VM use the tab to autocomplete so I don't have to type all that stuff and get it wrong and make mistakes and you guys laugh at me and then I'm gonna tell it where I'm gonna send it now what was that IP address again let's go over here in double check so currently this is 192.168.0 to three I'm using a bridged adapter and that changes every now and again when the in a virtual machine so I have to kind of double-check that so I'm going to send it to this machine 192.168.0.1 and this tells that we're actually going to transfer a file if you don't have the colon in there then it doesn't know where to put it it has no clue and if I just leave it empty like that it'll just throw it into my accounts home folder on that machine but I want it to go a specific place so I'm going to use the tilde to represent my home folder and we're going to put it on the desktop and another slash tells it that I don't want to try and replace the desktop I want it on the desktop thank you okay go and we haven't connected to that machine before so it prompts us to say is this really okay I do not have the key authentication set ups now it's asking for a password if I was going to keep that VM around permanently I would but for this it works fine and now you'll see that the file has transferred itself it is now over on the other machine and we can verify that simply by coming over here and we will clear the screen and now what we're going to do is is CD desktop list storage yep our file made it over there everything's cool but if I can't physically get into the machine to do that like I can here with a VM I can always double check that by just it asks for the password and now I am logged into that virtual machine CD that's top list the storage and you see our file is there so there you go that's basically how that works and after you get used to doing it that way you don't want to drag and drop into a Samba Network and you don't want to put it on local area storage and then go pull it down on the other machine and all that stuff no no no you can just send it directly through it just goes straight to the machine no big deal and it's very easy to do one of the other things about SCP that's really nice is that it is very very tenacious it will make sure that those files get over there even if the internet connection is a little wonky so if it stops in the middle and you end up having to reconnect for some reason then it will pick up where it left off and it is sent securely so if you're doing it over a network that you think might be you know easily compromised it's gonna be really hard for somebody to sniff the data going by and figure out what you're sending so lots of advantages there ok so let's go ahead and get out of that virtual machine because the next thing I want to show you is that some practical ways that you can use all this technology to do something that is useful so let's go ahead and clear that and what we're going to do is let me just go ahead and go back to the home directory there now what we're gonna do is I'm going to install an application on another machine and I'm going to configure that application without actually sitting in front of the machine and I do this all the time so if I find a really groovy program and I want it on all of my computers then I can just log in and do this so I'm going to show you how to do that right now ok so let's login to the machine we want to get into so we'll just change that last number to 17 and I don't care if you know these IP addresses because it's on my internal network and you can try all day and all night to get into my network but all of this operates behind a firewall so it doesn't make any difference you're never getting in and if you do have SSH and you want to configure it where you can log into somebody's computer over the internet across town that's an entirely different thing chances are you will have to change your router to make an exception for that so that it can be heard on the network and you must make sure that it's very secure use key authentication if you can simply because of the fact that if anybody can see SSH on the network you can bet that some bot is going to come by and bang on it but this is all on just my local machines here so we're into this machine and I want to install the application that we're using right now which is Terminator Terminator now we're installing loops I have to put install in there dummy okay here we go now it's installing on this machine and the way we go so I have Terminator installed on the other machine but I don't have it configured I want it to look like what you're seeing here now I could wait until I got up there and went over to that machine launch the application and configured by hand but why do that when I can just move the already configured file over to that machine that has all of the configuration that it needs so what we're going to do is let us split this screen now we're on the local machine Terminator is installed here and I'm gonna change my directory to dot config where I know the files are kept and just to show you guys you see that there is a directory here called terminators so all of the settings for terminator are in there so now what I want to do is move this actually copy this directory over to the other machine and we'll use SCP to do that removing a directory so give it the recursive flag and we're going to move terminator let's see if I put in term if that's enough yep that auto-filled don't need that extra slash there but I'll put it in there anyway where are we sending it 192.168.0.1 seven and if I put a coal in there that tells it I want it to go in home directory but in this case I want to put it in the dot config directory within the home directory so I'm gonna go ahead and give that a specific path so we have home and we're gonna put it in dot on big sure I type that right and now we put the slash there to just let the system know I want to in that directory I'm not trying to replace it and off it goes I've got everything right Oh believe me when I'm actually doing this and I'm not trying to make videos and think at the same time I type a lot better somebody put a comment up that the other day it's just dyslexia I cannot type and talk at the same time anyway here we go so I have transferred my files over there so the next time that I go over to that machine is sit down and I bring up terminator guess what it's already going to be configured it's going to be ready to rock and roll so that is the basics of SSH and SCP moving files back and forth now some of the tools that you can use within SSH for instance let's see here maybe you want to just check and see what's going on with that machine I think I showed you guys users already so users users thank you just me on there I did show you that also if I want to know what the computer is doing at that moment let's say somebody's using it I want to know how hard it's working I can use H top which is one of my favorites if I want to check on disk storage over there and see how that's going then I can use DF not only will this show me what all of the disks are doing and how much space is available on the middle also show me things that are mounted to the machine like USB devices Mass Storage and things like that so DF is a good command to get to know and if you just want to know what's going on with memory free is good and I'm using that H on there to give humanly readable output because if you don't this is what you get see it's a lot easier to use that we've talked about these commands in the past and I think that's pretty much all I wanted to talk about in this video except that I did want to talk about how you control powering off the machines so once you're done you may want to restart the machine or you may want to power it off for instance with this Dell laptop machine right here I want to turn it off so we're going to use sudo power off and now that machine has turned itself off and it says that the connection is closed and we can reboot a machine that is somewhere else by just entering doing the command some pseudo reboot it would do the same thing of course I'm not gonna do that because that's a machine I'm on right now and it would restart the machine so I think that's about all I wanted to show you and believe it or not with just those tools right there what I showed you and you can administer the entire network and once every couple of days when I think about it I sit down here and I open up all of the screens and I login to all the machines okay like I can I can have three machines on the same screen here so we have the HP here so let's go ahead and login to you know go ahead and login to the one in the back again alright I can just sit here and have commands running very cool so I wanted to show that to you guys hopefully you got something out of the video I know it went really fast and I know that I glossed over a lot of things but the information on how to do all this stuff is either already on my channel or out there on the internet and I just wanted to kind of do an update and show you guys how I was doing those sorts of things please check out easy Linux on the web check out easy Linux on Facebook also check out easy Linux calm if you want me to help you to get started with Linux I'll be glad to step you through the installation process yes I want to close the terminals thank you and I want to close this video as well also check out freedom penguin comm for lots of great stories about Linux and from that's from contributors like myself I haven't put anything up there for a while but a lot of great articles have showed up from other people as well so do check it out all right we're done
Info
Channel: Joe Collins
Views: 21,004
Rating: 4.9205775 out of 5
Keywords: Linux, SSH, SCP, Network, Computer, Laptop, Desktop
Id: KzSYG0Tah7E
Channel Id: undefined
Length: 24min 14sec (1454 seconds)
Published: Thu Aug 18 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.