Skip to playerSkip to main content
Want to set up a Raspberry Pi without plugging in a monitor? This headless setup guide is for you! Follow along as we download the Raspberry Pi OS, flash it to an SD card, enable SSH, set a static IP, and connect remotely?all in minutes. Ideal for servers, experiments, or anyone who hates extra cables. No desktop needed, just a Pi, SD card, and Ethernet. Check out my other videos for SSH key setup and Linux tips. Subscribe and join the community for more Raspberry Pi projects!

#RaspberryPi #HeadlessSetup #PiProjects #TechTutorials #Linux #SSH #DIYTech #RaspberryPiOS #RemoteAccess #TechForBeginners #PiServer #Electronics #MakerCommunity #RaspberryPi4 #RaspberryPi5

Introduction to Headless Setup 00:00:00
Why Headless Setup 00:00:06
Equipment Needed 00:00:28
Downloading Raspberry Pi OS 00:01:24
Choosing the OS Version 00:02:05
Unzipping the Image File 00:03:52
Writing Image to SD Card 00:04:12
Handling Auto-Mount Issues 00:05:02
Checking Disks with Parted 00:05:36
Unmounting SD Card 00:06:49
Using DD Command 00:08:02
Enabling SSH on Boot 00:12:07
Setting Static IP Address 00:12:33
Configuring SSH Keys 00:14:54
Setting File Permissions 00:16:36
Unmounting and Final Setup 00:18:55
Connecting to Pi via SSH 00:20:04
Verifying Connection 00:21:23
Conclusion and Next Steps 00:22:04
Call to Subscribe 00:22:52

Thanks for watching!

Find us on other social media here:
- https://www.NeuralLantern.com/social

Please help support us!

- Subscribing + Sharing on Social Media
- Leaving a comment or suggestion
- Subscribing to our Blog
- Watching the main "pinned" video of this channel for offers and extras
Transcript
00:00Hey there, let's talk about how to install your Raspberry Pi from scratch and get to first boot
00:06and first login without actually having to plug in a monitor at all. This is a pure headless
00:11setup because for me personally, I hate walking over to like a TV or a monitor or something
00:16and plugging the Pi in or getting my portable monitor out. It's just a pain in the butt.
00:20I'd rather just, you know, manipulate the SD card, get it all installed, and then connect to it and
00:31configure it right away. Of course, this video assumes that you're not going to use your Pi
00:35with a desktop or a monitor at all, because if you are, you might as well just start doing that.
00:41But for me, you know, a lot of my Pis are just headless. They're servers or they're fun experiments
00:45or whatever. So the first thing that we should do, obviously you need an SD card and you need an
00:52SD card reader. So if you're on this video, you probably already have like an SD card and an SD
00:57card reader. This is like a super old reader where you could stick a card in there. I got a slightly
01:02newer one plugged into the computer right now. And if you bought an SD card or a micro SD card with the
01:08Pi, you probably had a little adapter that came with it, a regular SD card adapter. So you can stick the
01:13tiny little card into the adapter. But if you're lucky and your, your card reader has a slot for
01:19micro SD, you probably just need that. So the first thing that you should do is go over to
01:25raspberrypi.com. Their foundation has a common org. I think org is more for the community, but go to
01:31raspberrypi.com and then click on software and download the Raspberry Pi operating system. So I'm going
01:39to do this the manual way. I'm just going to write an image. If you want to do this with an imager,
01:43or if you have like something else that you already know how to do, that's totally fine.
01:46Go ahead and do it. I really just want you to put the operating system onto the card.
01:50Check my other videos because I'll be posting about how to do this with windows and other stuff.
01:59I guess you don't need that if you're going to use the imager, but it's more fun to do it manually.
02:02All right. So notice how it says manually install an operating system. I'm going to click on the
02:06download options, select the operating system. So modern Pis can use the 64 bit OS. That's what
02:14I'm going to do. If you have, I think like a Pi one or two, you might be stuck using the legacy,
02:20like the 32 bit. What's the difference between those two? 32 bit. Oh, don't do legacy. I think
02:25that's like really old. I don't know. Maybe it depends on how old your Pi is, but just hover the
02:31mouse and notice how one of them says 32 bit. That's what you would use if your, if your board
02:35is not 32. But as far as I understand, I mean, definitely the Pi four and the Pi five for me,
02:41they worked with 64 bits. I think my Pi three worked with 64 bits, although I'm not 100% sure
02:47everything was okay after install. So just basically click on that. Then it'll ask you, all right,
02:53what, what version of the 64 bit do you want to download? Uh, if you're going to be installing a
02:59desktop, you don't really need this video. So I'm just going to assume you don't need a desktop.
03:02You want this to be totally headless. So that means the desktop is too much. It's too much to
03:06download. It's kind of a waste. Same thing for a desktop with recommended software. Instead,
03:11I'm going to click on the light version because that's the fastest to download and it's all we
03:15need. So I'm going to click on that and it'll download. And, um, you could probably pause the
03:20video right now because I already downloaded this. So pause the video and then wait for your download
03:24to finish and then come back with me. This is where I chose to save my image file.
03:29Um, you probably actually don't have a dot image file. Uh, you probably have an image that ends in
03:37the XZ extension. If we look at the website again, at least as of the time I made this video, notice
03:43how the URL at the very bottom of that says dot XZ at the end. That just means it's a zipped image
03:48so that it's faster to download. Um, so in order to unzip that and make it a regular image, you basically
03:55say un-x-z and then type the name of the file. Uh, actually it would probably end in XZ if you had it.
04:03So you just kind of wait a little while for that to unzip and then when you're done, it'll show the image
04:07file like I have. Okay. Anyway, so now that we've downloaded the image file, the next thing we need to do
04:13is actually write to the SD card. So I'm going to take the SD card right now and stick it into the card
04:18reader. Um, this is going to be awkward. Awkward. My giant fingers aren't working.
04:36Oh, I almost did it. I almost got it. Oh man.
04:41Welcome to my life.
04:52Bro, I need a flashlight or something.
04:58Oh my God. Finally, finally, finally. Okay. I am kind of in a dark room and it's like upside down
05:06and my hands are big and it's like way over there. It's already plugged in. I didn't want to unplug the
05:10card reader because sometimes they, uh, they don't show up again if you plug them back in and you have
05:14to like reset the USB root hub. I really didn't want to do that. So, uh, let's see. The first thing
05:23that you probably should have done actually before plugging in the SD card. So maybe unplug your SD
05:26card real fast. Just, uh, just to check is, uh, just take note of what's already plugged into your
05:31computer. I already know. So it's fine for me, but for you, you probably want to run a program called
05:36PartEd, uh, which is short for partition editor. It'll just show you what discs and partitions and
05:41stuff you have in your system. So I'm going to run it. Uh, if you don't have it, it's probably for
05:46you. Pseudo app install PartEd. I'm going to do print, uh, devices and Oh, okay. I'm on a host
05:55machine right now. I got to send that USB into the guest. So I guess it, it all worked out. Notice how
06:00it's telling me this is the only disc that's present. It's like my 200 gigabyte virtual machine disc.
06:04So then I'm going to tell my host machine to give that card reader to the guest machine,
06:10USB host device, card reader, finish. Hopefully the video didn't skip or do anything weird.
06:16And then if I do print devices again, now another thing showed up and, uh, I'm, I'm able to access it.
06:24I know for sure this is dev SD. God damn it. I know this is dev SDB because that's what just showed
06:32up. So remember that that's very important. Uh, you don't want to get that wrong. Um, notice these
06:37annoying pop-ups that happened. That's because there was already a file system on the card.
06:41Cause you know, I play around with these things and it's not erased right now. So that's okay.
06:45You can just close these little pop-ups if you're, if you're a Linux auto mounts or anything like that,
06:50but you have to unmount before you start writing to the card. Because if you write to a card or a drive
06:56or anything that's already mounted somewhere, like then you're probably going to corrupt your data.
07:00So I'm going to do Mount just to check what the mounts are. And I'm going to search for SDB since
07:05I know that's the device that just showed up. Uh, so it's telling me that it's mounted on those two
07:10folders, which we recognize at this point, uh, cause we just saw them pop up. So I'm just going to
07:15unmount them real fast to make sure that I don't screw anything up. Okay. All right. And then, uh,
07:23one more time mounts, uh, pattern matching with grip against SDB. Now they're gone.
07:30So it's probably safe to write to the SD card now. So, um, the first thing that I'll do is I'll say
07:37pseudo actually, let me just list real fast the image. Okay. So we're going to write the image to
07:44the SD card using that card reader. Um, I should probably also point out that if you don't understand
07:49what I'm doing on the command line, you could just follow along, but I have other videos that are
07:53you know, fairly decent tutorials on using the command line and connecting to machines over
07:58the remote and making SSH keys and stuff like that. So I'm going to go ahead and use a command
08:04called DD, which writes, uh, directly to some drive or block device. Uh, it's very, very dangerous. So
08:11be careful. You could destroy your whole computer this way. I actually did this once a long time ago.
08:16I didn't check what the output specification was. And I watched my computer totally erase itself
08:21and a little tear went down on my cheek. So we'll specify the in file IF equals, and that's pretty
08:28easy. I just have to specify the image I just downloaded. Make sure you unzip yours before you
08:32do this. Then the out file is going to be the block device that just showed up dev SDB. Uh,
08:40if you see other tutorials on the internet with like, you know, SDB one and two, those, those numbers
08:45after the SDB or the block device, those usually are just partitions. So you want to write the whole entire
08:50card or sorry, the whole entire image to the whole entire card. You don't want to specify a partition.
08:56I'm also going to specify conv equals F sync for me. It's a little bit safer. I don't know if this
09:01is needed on SD cards, but for USB thumb drives, they'll sometimes lie to you and say that data has
09:07been written, even though it has not in order to appear faster than they really are. So if you do conv
09:13F sync, it makes that safe again. Cause you don't want to, you don't want the command to say that it's
09:18finished writing and it's not. And then you unplug the device and then whoops, you have corrupted data
09:23now cause it didn't finish. Uh, and then I'm going to do status equals progress just so I can see what's
09:29happening. Okay. So, uh, at this point now we're just waiting. I'm going to watch the progress for
09:38myself very carefully. And then I'm going to, uh, I guess I'm going to pause the video and I'll come
09:45back when it's done writing. And so you should just probably pause the video right now. And then
09:50when your card is finished writing, then come back and resume with me. We'll do, uh, an initial IP
09:57address and we'll connect to it. Uh, we'll set up the SD card and all that stuff without ever plugging
10:01in a monitor, totally headless. It's pretty sweet. Okay. I'm going to pause.
10:09Okay. I'm back. So I had an issue that I want to share with you real fast. Uh,
10:14what happened is while my SD card was writing, the auto mounting service just came up and produced a
10:20folder and, uh, I get, I got kind of scared. And then when I went to go into the files,
10:25I started getting read, write errors. So I think I actually corrupted my card.
10:29I ended up, um, disabling the service that auto mounts and then writing the card again from scratch.
10:34So just for you, the command that you would probably need, if you have the auto mounting
10:40service enabled on your machine is sudo system control, stop udisk2, udisks2.service.
10:47You don't want to disable it because you probably want it running after you're done doing all your
10:51installs, but you want to do stop so that it stops right now and then start the SD card writing
10:57all over again from scratch. So with that in mind, um, let's see, hopefully this is going to show up
11:04now. Pseudo parted and then I'll do print devices again to see what's up. Okay. So it's in there.
11:11Now let's see if we have read, write errors or if it's actually going to work this time.
11:14So I turned off the auto mounting service, which means I have to mount it from scratch probably.
11:22So let's just double check to make sure it didn't actually mount
11:25media mic.
11:28Okay. So nothing's in there. So that's good. So now I am going to go into the temp folder
11:32and then the pie folder and then the boot folder and the root are just going to be mounted. So I'm
11:36going to say sudo mount
11:39vice sdb. Is that what I just saw? I forgot sdb. Yeah. sdb1 goes to boot.
11:46Um, and then sdb2 goes to root. And now we have access hopefully to the file system. So I'm going
11:56to go into the boot file system. So this is the boot partition that your pie will have when it's
12:01running and stuff. So first thing we need to do is tell the pie that we want its SSH server to be
12:07enabled at boot. There's not really that much that we have to do here. We'll just basically create an
12:12empty file with the touch command. So I'm going to say touch SSH. And now if you look, there's an
12:19SSH file, it's totally empty, but that lets the pie know that we want the SSH server to run
12:26whenever it boots. Then we have to modify the command line so that we can set a fixed IP in advanced.
12:33So, uh, you know, sudo nano command line or Vim or whatever you like to use. What you're looking
12:37for here is root weight. Right after that, you have to put the specification for the IP address that
12:43you want. So you probably should know what your IP address sub, what your IP subnet is before you
12:49start. We're not going to do IPv6 in this video, but you know, cause we just need IPv4 to get into the
12:54pie. Uh, and then from that point you can configure it however you feel like, but so most people's
12:59routers are 192.168.1.1 or sometimes 0.1, whatever yours is, you have to figure it out. You have to
13:07go find out what your router's IP is. Your subnet is probably just the first three numbers because
13:13most routers, uh, consumer routers default to a 24 block, which just basically means the first 24
13:18bits have to stay fixed. And the last eight bits can change for an IP address to be considered in the
13:23same subnet as some other. So for me, I know mine is a dot one dot something. So I'm going to assign
13:29123 to my pies, uh, ethernet adapter. Cause that's just what I want. You have to choose a number
13:36that's available on your network. If you don't really know, um, then it probably won't matter
13:41too much because if you fix a number that's already in use, the other computer will probably get kicked
13:46off the network and then try to rejoin. And then it'll end up using a different number.
13:49Most DHCP servers that I've seen on consumer routers will kind of stop at high numbers. Like
13:56they'll go from two to 99 or something like that. So if you want to be like a little bit on the safer
14:01side, you could choose a higher number. Um, but it's fine. So right after root weight, IP equals,
14:08and then the IP address that you've chosen. So that's it for the boot partition. Let's go into
14:13the root partition now. So the root partition is just like the root of the file system.
14:18It's got, uh, the actual root folder. So that's the home directory for the root account.
14:22We could go in there and modify, uh, that if we wanted to, but I just like to modify the
14:27PI account because every PI, uh, by default with these OS installs, it comes with an account called
14:32PI and it's also an admin. Uh, so it's home folder is going to be the root of the file system slash
14:37home slash PI. But for this particular amount, you know, it starts at root. So we have to go CD into
14:44home and then CD into PI. So from your PI's perspective, it's just going to be this folder
14:49right here, slash home slash PI. Uh, I've mounted it. So I see a different path. If I list it,
14:54you can see some starter files for the PI. So I'm going to create a directory.
14:58I can do make directory and call it dot SSH, a special folder where all your SSH configuration is.
15:08Again, if you don't understand SSH or keys or anything like that, see my other videos. I'll
15:13talk about how to make SSH keys and connect from windows and connect from Linux and all that stuff,
15:17but it's, it's not too bad. You can just kind of follow along with me. If you don't have a key,
15:21by the way, on your host machine. So let's, let me go up here on the host machine.
15:27Um, you can do something like SSH dash key gen type ED25519, and then just hit enter a bunch of times
15:34and you should be able to get your SSH key created. Uh, you probably want to eventually
15:39learn how to put a password on it, you know, but that's okay for now. So I'm going to go into the
15:43SSH folder and I want to create a special file called authorized keys, meaning I want to authenticate
15:52some SSH keys that will be allowed to connect into the PI. So for my host machine, I'm going to
15:58print out my public key, at least for this, um, oh, ID, right. I got to do ID, ED dot pub.
16:07So this is just like a useless key. I mean, the public keys are always okay to share on the internet.
16:11It's fine. But like, I feel better about this because it's just my VM for videos. It doesn't
16:16actually run most of the time I've lost. Okay. Something happened. Okay. So basically you just take
16:24this key, the whole entire public key, get the pub, not the one that doesn't have pub and just paste
16:29it into authorized keys file. So then we have to, uh, set permissions. Um, the authorized key file,
16:38we're going to go to mod. I think it's supposed to be like six or seven. Oh, oh, but basically, uh,
16:44the system probably doesn't want any other user to have permission. So that's why we do
16:49something zero, zero, either six or seven. I think six might be it, but I'm just going to stick with seven.
16:53Just to help this video go along a little bit faster, uh, make sure it's owned by, uh, the same
17:00user as the pie. In this case, the pie user is just sort of like the first user that was created.
17:06So it'll end up having the same user as you, if, if on your host machine, you are also the first user.
17:11If not, you're probably going to have to figure out how to set a different, uh, um,
17:18user owner, or maybe just do the root account instead. Maybe I'll show you that real fast.
17:25So then we go up one level and the system probably also does not want the SSH key to be,
17:30uh, you know, or SSH folder to be browsable by other users. It's also kind of a bad idea.
17:35So I'm just going to go to mod. Um, we'll do like another seven 00 SSH. It definitely has to be
17:41seven 00 instead of six 00. If you don't know permissions, by the way, then just see my other
17:45videos. Otherwise, trust me, but long story short, not a good idea to be able to let other users into
17:50your SSH folder. So that's why I'm doing that. Uh, at this point, we're probably done authenticating.
17:57We can probably jump into the pie, but let me just show you real fast. If we go into the root folder,
18:02mission denied. Okay. Sudo su root and then go into the root folder. Notice how if we're in temp
18:12pie root, that's the root partition. So really from the pies perspective, we're trying to edit a file
18:19called slash root. Cause that's the home folder for the root account on the pie. Uh, it's basically the
18:24same thing. There's like an SSH folder in there and you can add an authorized keys file. If you want
18:30to be able to log into the root account on your pie, otherwise it doesn't really matter. Uh, and I
18:35think we're probably done. Let me just double check my notes real fast here. Oh no. I forgot to look at
18:40my notes first connection. Did I forget anything? I probably forgot a bunch of stuff, authorized keys.
18:49All right. Let's see if it actually works. So I'm going to now, um, unmount got to do that. Don't
18:56forget to unmount. So I'm going to go sudo umount boot, sudo umount root. If either of those say the
19:05device is busy, you probably are still in that directory in like a different terminal tab or
19:11account or something. You know, one of the mistakes I always make is I go sudo su root. And then I
19:17forget that the regular user is actually still in that same folder, even if I navigate to somewhere
19:22else in the root account. So just make sure everything's okay. Uh, and then you can,
19:26if you want to double check, you can say mount, mount points, um, boots and mount points root.
19:31And it'll tell you that they're not mount points. So at this point, it's probably okay
19:37to remove the card from the card reader, remove the micro SD card, stick it into the pie.
19:43And then, um, uh, I'm going to plug the pie into ethernet because that's the IP address that I
19:52just set up. So I'm plugging it into the ethernet real fast. You can't see it's off camera. I have
19:57a short cable and then I'm going to plug it into its power. So now my pie is totally on
20:04and I'm going to start trying to ping that IP address as fast as I can. I should have started
20:08pinging before anything happened because it's more fun to see when the pings begin. Would you agree?
20:16No? Okay. Uh, let's see what's happening. I see some flashing on the ethernet cable and the power
20:24lights. I always get nervous that I've done something wrong when I'm being recorded because,
20:29you know, in regular life, I do stuff wrong all the time and it's fine. Nobody remembers.
20:34I just have to like quickly catch myself and correct my mistakes.
20:45Awkward. This small amount of time has turned into a huge amount of time in my mind.
20:54Wait, what am I doing? What am I doing? Oh, that's what happened. Oh, a huge mistake.
20:58I forgot to put an extra number there. For some reason it filled into zero.
21:01I was too rushed. Okay. So the pie probably came on a long time ago. You're welcome for the laugh.
21:10So now that the, uh, the pies online, I can try to SSH into it and just hope that my authentication
21:15works. So I'm going to do pie at, because I didn't make a user account that matched to Mike. I just
21:21made a pie user account. So I'm going to do that and host verification has failed. So that just is
21:26because I've been using that same IP address for different videos today. So I have to remove that
21:32from the memory of my SSH clients. I'm going to go SSH keygen or this is a good security feature.
21:37Basically it's saying that your system remembers connecting to a totally different machine at
21:43that same IP. So it thinks somebody is being hacked. So I'm just going to remove a record, the record
21:49and then try to connect again. Now it's going to say, all right, do you want to connect?
21:53Do you trust this? I guess I do probably. And, uh, here we are. We're inside of a raspberry pie now.
22:00Um, this is basically the end of the video because you can kind of do whatever you want now. Notice how
22:04I never plugged in HDMI. I didn't have to look at a desktop. I didn't have to do anything
22:09except just connect to the pie over the network. For me, this is really convenient. You just write the SD
22:15card, modify a couple of things, plug into ethernet and then boom, you can configure it. So you can go into,
22:20you know, network manager and like look at the connections and modify them, set the IP addresses
22:25however you want, set any other configuration any way you want, harden the security. So the point of
22:31this video is just how to get in, uh, without really plugging into a monitor. So thank you so much for
22:37watching. I hope you learned a little bit of stuff and had a little bit of fun. I, uh, suppose I will see
22:42you in the next video, Hey everybody. Thanks for watching this video again from the bottom of my
22:56heart. I really appreciate it. I do hope you did learn something and have some fun. Uh, if you could
23:01do me a please, a small little favor, could you please subscribe and follow this channel or these
23:07videos or whatever it is you do on the current social media website that you're looking at right
23:11now? Um, it would really mean the world to me and it'll help make more videos and grow this community.
23:17So we'll be able to do more videos, longer videos, better videos, or just, I'll be able to
23:21be able to keep making videos in general. So please do, do me a kindness and, uh, and subscribe. You
23:27know, sometimes I'm sleeping in the middle of the night and I just wake up because I know somebody
23:31subscribed or followed. It just wakes me up and I get filled with joy. That's exactly what happens
23:35every single time. So you could do it as a nice favor to me or you could, you could troll me if you
23:40want to just wake me up in the middle of the night, just subscribe and then I'll, I'll just wake up.
23:44Uh, I promise that's what will happen. Also, uh, if you look at the middle of the screen right now,
23:49you should see a QR code, which you can scan in order to go to the website, which I think is also
23:53named somewhere at the bottom of this video. And it'll take you to my main website where you can
23:58just kind of like see all the videos I published and the services and tutorials and things that I
24:02offer and all that good stuff. And, uh, if you have a suggestion for, uh, uh, clarifications or errata,
24:12or just future videos that you want to see, please leave a comment. Or if you just want to say,
24:16Hey, what's up? What's going on? You know, just send me a comment, whatever. I also wake up for
24:20those in the middle of the night. I get, I wake up in a cold sweat and I'm like, it would really,
24:26it really mean the world to me. I would really appreciate it. So again, thank you so much for
24:30watching this video and, um, enjoy the cool music as, as I fade into the darkness, which is coming for us all.
24:39Bye.
24:40Bye.
24:41Bye.
24:41Bye.
24:41Bye.
27:39Hey there, let's talk about how to boot your Raspberry Pi or art on yourself.
Be the first to comment
Add your comment

Recommended