How to Enable SSH on a Raspberry Pi (and connect via IP)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is tony such as tech i'm tony and in this video i'm going to show you how to enable ssh on your raspberry pi now real quick for anybody out there who doesn't know what a raspberry pi is this is a raspberry pi it's a single board computer that sells for less than 50 this one is a raspberry pi for the newest version as of now late 2020 and you can do a lot of different things with this but this channel at least for now i'm going to make some other videos about how to host a website on a raspberry pi so if you're interested in learning how to do that definitely check out some of those videos but for now the foundation we will have to first install an operating system enable ssh i'll show you how to pre-configure the raspberry pi to automatically connect to wi-fi and then i will show you how to determine the ip address of the raspberry pi and i'll actually show you how to log in via ssh as well and also at the very end i'll show you how to give it a host name so you don't have to remember the ip address you can just remember a user-friendly host name so that's something you want to learn how to do let's go ahead and get on into the tutorial here the first thing i'm going to do is to take my micro sd card and plug it into my computer so we can load on the operating system so i'm going to go ahead and plug that in and you should see that pop up on the screen here the device um there it is so it's called untitled right now and what we're going to use in order to image the micro sd card with the operating system is the official raspberry pi imager if you don't already have that you can go to raspberrypi.org under the software section and download the raspberry pi imager for whatever operating system you're using i'm on mac os and i already have it installed so i don't have to worry about that i can just open it up let me go ahead and open that up and there we go so there's basically two three steps here we have to choose our operating system choose the sd card and write the information to the sd card so let's go ahead and go through that choose the operating system you have lots of options here but for this let's work with the raspberry pi operating system and i'm going to use a headless version of raspberry pi operating system which is in this section here you can expand that and i'm going to use this one with no desktop environment and what that means is there's the only way to access it is via ssh this the rest of this tutorial will work with other versions of um raspberry pi os but this we don't need the desktop environment we just need the headless server environment so i'm going to click that and then i'm gonna choose my sd card which is going to be um this one the 64 gigabyte one right here i'll click on that and then i will click on write so it's just saying uh this warning right here that everything on the sd card will be erased so make sure you don't need anything on there because you're not going to get it back so that's fine with me i'll click on yes and i will type in my credentials and this will take you know a few minutes to to write all the information that sd card so i'll pause the video and catch back up with you when it finishes okay guys i'm back just a few minutes later and the writing has finished the operating system is now on the sd card so it's telling us that we can remove the sd card from the reader so we can click on continue and we're actually done with the raspberry pi imager for now so what i'm going to do you'll see that the device has gone away what i'm going to do is pop the sd card out and then plug it back in and maybe it'll pop up on the screen maybe it won't but what i'm going to do is ultimately drag that device onto the screen so you can see what it looks like now so now the device is called boots and i can put that anywhere really in here we have all the files that it wrote during that writing process and what we want to do is to enable ssh is to create a file an empty file in here called ssh that's all we have to do to enable ssh so if you're on windows on mac or whatever you can do this i'm going to actually do this with a terminal window and we can watch it happen in real time here so what we're going to do is just type like if you're familiar the touch command that's just gonna create an empty file and this is at my volumes um directory in here i have the boot device and right in the root of the boot device we just to make a file called ssh empty file so i'll execute that command and here you can see that that ssh file has been created it's empty zero bytes that's that's nothing nothing it doesn't have to contain any content that's all i'm trying to say so that enables ssh but because we are working in a headless environment and there is no way for us to ultimately type in the wi-fi password you can if you don't want to connect video wi-fi you can plug in a ethernet cord but i think the easier way if you do have access to wi-fi is to already pre-configure your raspberry pi with your wi-fi credentials so i'm going to do that here and it's going to be a similar similar concept we're going to create a file in here with the credentials of our our wi-fi network so we can do that with any text editor you can right-click here make a new file if you're on windows but i'm going to do it through the command line again so same type of thing at volumes inside the boot device we want to make a file called wpa underscore supplicant dot com so let me just make sure we got that spell right it's wpa underscore s-u-p-p-l-i-c-a-n-t dot conf and in here uh i'm gonna use my cheat sheet over here and actually i'll have this linked down in the description below so you can copy and paste and modify as necessary rather than typing it from the screen we have these few configuration options so in here you are going to keep everything pretty much the same unless you have or i guess the three things that we have to change in here i should say is your two letter iso country code which for me is us and then your wi-fi name which is going to be for me my wi-fi network is called saint ignatius and the wi-fi password which i'll pause the video here and type in so you don't know what the wi-fi password is but type your wi-fi password in here in quotes instead of this go ahead and save the file and then i'll catch back up with you when you're done with that okay so i have saved my file with my wi-fi password and we can see that was created down here wpa supplicant.conf so as far as enabling ssh and our wi-fi credentials are concerned we are good to go let's go ahead and eject this device from our computer we can do that by clicking on this button right here and i can physically remove this from my sd card reader take it out of here and plug it into the raspberry pi which is on the bottom you can slide it right in there and now we're good to go so let's get a power cable a usb c power cable plugged into either a wall outlet or your computer and plug it in and you will see some indication of it booting up which this is not plugged in just give me a second okay so you'll see these two led lights at the bottom right hand corner one of them red one of them green as it's booting up and we'll give it um you know 30 seconds to a minute to boot up before trying to attempt to find out what the ip address is um let me just put that there so it doesn't fall uh but that's the next step in this process we want to know what the ip address is so we can ssh in and in order to do that we're going to use a command uh the ping command if you're not familiar you can ping a website and get back the ip address so just for demonstration purposes let's ping google.com and it's going to reply back to us with the ip address of google so we can use the same concept we can ping the raspberry pi we can ping its device name and it should give us back the the the ip address so let's try that if we ping raspberry pi and this is just this is a dot local this is just a default name that comes pre-configured with the operating system it's going to be given this name raspberrypi.local and if it's up and booted it and ready to go it should respond to us with the ip address so let's test that out and we're getting back the ip address so the ip address of our raspberry pi is 192.168.0136 so what we can do now is we can log in via ssh to our raspberry pi with this ip address so we can do ssh the default username for raspberry pi operating system is pi and then you can say at the ip address so either copy and paste it or type it in at the ip address hit enter and because i have previously logged into this raspberry pi i actually have to at this ip address i have to get rid of that please ignore this if this if you don't get this error message but this is just how i'm going to um uh undo my previous login session from that so uh go ahead type that in if you're if it's not working you might get this error message it's not an error message it's a just a warning and yes saying do you trust this connection and you can go ahead and type in yes you trust it and that's going to add that information into your list of known hosts and then if it's ready to go it should eventually prompt us for the password there we go and the password the default password for the raspberry pi is raspberry so type that in hit enter and now we are logged into the raspberry pi so this is a terminal window inside of the raspberry pi we can do a u name dash a to see what type of operating system we're running linux raspberry pi version 5.4.51 arm processor just just i guess to prove that we're actually on the raspberry pi let's get out of the ssh session and i just want to show you one last thing that you can do that i think is pretty cool might be helpful for you and that is uh adding a host name for your raspberry pi so um instead of memorizing this ip address you can give it a custom host name and i'll show you how to do that on mac and that same concept applies for linux if you're running linux but i also have a video about how to do this on windows it's slightly different but what we're going to do is edit a configuration file on our computer at etc hosts and in here i have to type my password in here it's just a list of ip addresses and host names so in here i can give it the ip address of my raspberry pi [Music] 192.168.0.136 and then tab over and give it a name that i will easily remember so let me just call let me call my raspberry pi raspberry okay so now instead of typing in the ip address like ssh pi at 192.1680136 i can do ssh pi at raspberry so we'll save that file and we'll give it a go so ssh pi at raspberry hit enter are you sure you want to continue connecting you're not going to get that every time only the first time that you connect at this device name hit yes or type yes hit enter enter the password again the password is raspberry hit enter and we should be logged in in just a few seconds oops i typed the password wrong there we go so now we're back logged into the raspberry pi via ssh hope this tutorial was helpful for you guys if you have any questions let me know in the comments below like i said i have some other videos on this channel about how to host a website on a raspberry pi so check those out if you're interested thank you guys for watching i'll see you in the next [Music] you
Info
Channel: Tony Teaches Tech
Views: 156,934
Rating: undefined out of 5
Keywords: raspberry pi ssh, enable ssh raspberry pi, how to ssh into raspberry pi, raspberry pi enable ssh, how to enable ssh on raspberry pi, connect to raspberry pi ssh, raspberry pi ssh password, setup ssh on raspberry pi, enable ssh raspberry pi headless, find raspberry pi ip, find ip address of raspberry pi, how to find ip address of raspberry pi, how to find raspberry pi ip, raspberry pi static ip address, raspberry pi ip
Id: 63yw7b0NuWc
Channel Id: undefined
Length: 12min 59sec (779 seconds)
Published: Fri Dec 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.