How to Connect Raspberry Pi to a Laptop in 6 Easy Steps

  1. Make Sure the OS Is Installed on the SD Card
  2. Configure the Wifi Connection on Your SD Card
  3. Turn on Your Raspberry Pi
  4. Connect to Your Raspberry Pi with SSH
  5. Install VNC Server
  6. Install a VNC Viewer on Your Laptop

After purchasing a Raspberry Pi and an SD card, you might not feel like going out and buying a display, mouse, and keyboard just to create a simple project. No worries! Together, a laptop and an internet connection are sufficient to get started on your Raspberry Pi. How?

1. Make Sure the OS Is Installed on the SD Card

Your SD might have Raspberry Pi Operating System installed. Otherwise, you can easily download the Raspbian Operating System and install it on a blank SD card.

For the rest of this tutorial, I will be assuming that your SD card has the Raspbian operating system installed.

2. Configure the Wifi Connection on Your SD Card

Now you’re ready to configure your SD card so that, on boot, your Raspberry Pi will connect to a wifi network. Once the Raspberry Pi is connected to a network, you can then access its terminal via SSH.

Insert your SD card into your laptop. You should see a /boot file folder show up. First, create a file named wpa_supplicant.conf in the /boot folder.

Information like accepted networks and pre-configured network keys (such as a wifi password) can be stored in the wpa_supplicant.conf text file. The file also configures wpa_supplicant—the software responsible for making login requests on your wireless network. So, creating the wpa_supplicant.conf file will configure how your Raspberry Pi connects to the internet.

The contents of your wpa_supplicant.conf file should look something like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=US

network={

    ssid="YOURSSID"

    psk="YOURPASSWORD"

    scan_ssid=1

}

The first line means “give the group ‘netdev’ permission to configure network interfaces.” This means that any user who is part of the netdev group will be able to update the network configuration options. The ssid should be the name of your wifi network, and the psk should be your wifi password.

After creating and updating the wpa_supplicant.conf file, add an empty SSH file in /boot. This SSH file should not have any file extensions. When the Rasperry Pi boots up, it will look for the SSH file. If it finds one, SSH will be enabled. Having this file essentially says, “On boot, enable SSH.”  Having SSH will allow you to access the Raspberry Pi terminal over your local network.

3. Turn on Your Raspberry Pi

Put the SD card back in the Raspberry Pi. Power on.

4. Connect to Your Raspberry Pi with SSH

Make sure your laptop is on the same network as the Raspberry Pi (the network in the wpa_supplicant.conf file). Next, you’ll want to get the IP address of the Raspberry Pi on the network. Run arp -a to see IP addresses of other devices on your network. This will give you a list of devices and the corresponding IP and MAC addresses. You should see your Raspberry Pi listed with its IP address.

Connect to the Raspberry Pi by running ssh pi@[the Pi's IP Address]. If this is your first time logging in, the default password should be “raspberry.” You can configure your own custom password after the first login.

You should now have access to your Raspberry Pi command line.

5. Install VNC Server

Now you have access to your Raspberry Pi terminal, but how do you see the Raspberry Pi desktop? You’ll need to install a VNC server. Running a VNC server on your Raspberry Pi allows you to control your Raspberry Pi desktop remotely on a laptop (the VNC viewer).

Realvnc-vnc-server worked well for me.  To install, copy the following into the terminal:

sudo apt–get update
sudo apt–get install realvnc–vnc–server realvnc–vnc–viewer

After installing the VNC server, you will need to enable it:

  • type sudo raspi-config in your terminal
  • A pop-up will appear; navigate to 5 “Interfacing Options”
  • Navigate to “P3 VNC”
  • Select “Yes”

Raspberrypi.org also provides a step-by-step guide on how to do this.

6. Install a VNC Viewer on Your Laptop

I installed VNC Viewer from RealVNC.

After installation, launch VNC Viewer, and type in the IP address of your Raspberry Pi as the VNC server address. If you’ve forgotten its IP address, just run arp -a again.

VNC Viewer will then prompt you for the Raspberry Pi default credentials. If you have not yet configured them, the default username is “pi,” and the default password is “raspberry.”

Congratulations! You should see your Raspberry Pi desktop!

 
Conversation
  • Prakash Wagle says:

    I recently bought Raspberry 4. This was very helpful.

  • Livia says:

    Hi! Thank you for this tutorial!

    I didn’t understand what did you mean by “ssh file” is there a format for this kind of file?

    Thank you!

    • Bontuken says:

      The “ssh file” is just a file named ssh that has no extension. I only got it to connect to wifi at first (except wasn’t sure wifi or ssh were working), and saw some other sources mentioned creating the file named ssh without an extension.

      • Lydia Cupery Lydia Cupery says:

        Yes, I agree – the ssh file should have no extension. So basically create a file named ssh that has nothing in it. The ssh file with no extension will enable ssh when the raspberry pi is booted up.

  • Ujwala says:

    Should we type the commands “arp -a” and “ssh pi@ [Pi’s IP address]”, on the laptop’s command prompt? If yes, then I did get a list of IP addresses for “arp -a”, but I’m not sure which one is my Raspberry Pi’s. So I tried using all the listed IP addresses in the command ” ssh pi@ [Pi’s IP address]” one-by-one. However, each time I ran this command it said ” ‘ssh’ is not recognized as an internal or external command, operable program or batch file”. Please help!!

    • mmd says:

      me too

    • Prackli says:

      you probably already figured it out, but for others if you run arp -a on your laptop it will give you your IP address not the pi. The best option to check for IP is login to your router admin page and check the connected devices, by default raspberry will show up as pi.raspberry or similar.

  • Sushant Pawar says:

    will it work if NOOBS is installed on the sd card

  • Hey! Thanks for the doc. Please correct “rasps-config” to “raspi-config”.

  • Hi Lydia,

    your manual is quite clear, thank you. I am facing however a problem. If I create the 2 files ssh and wpa_supplicant and copy them to the bootdisk I can see them on this disk in my laptop but if I put the disk back again in the Raspberry Pi 3B they seem to have disappeared. What can be the cause of this? I cannot move on with the other steps if the files keep disappearing after putting the disk in the raspberry. Hope you have a solution. I must be doing something wrong.

    • Jan de Quaasteniet says:

      Everything works fine now. I had to connect the RaspberryPi first with cable in order to be found :)

      • Mofakharul Islam says:

        Would you please let me know how you sorted out the issue? I followed the procedure exactly but still not able to get my Raspberry Pi on my laptop.

        • Jan says:

          Hi Mofakharul,

          you have changed the ssid and the psk in the .conf file? This is important!
          First you have to connect your RaspberryPi with an internetcable to your router.
          Then you have to install PuTTY. there you can fill in your IP address as follows: pi@your ip-addres (you can find your IP-addres using the code arp -a in the CMD screen.
          then you can fill in username and pasword: standard it is pi and passwd.
          if you do that you get to see some options: first change your password, then go to option 3 and change NO to YES. then you have to install the VNC viewer which you can find on internet. if you do that you have a graphical desktop for your RaspberryPi. hope I am a little bit clear :)

          • Jan says:

            oh PuTTY and VNC you have to inbstall on your desk or laptop

  • Patrick Scholl says:

    Hello,

    thanks for the nice article!
    I think in section 5 it should be “sudo raspi-config”.
    Your version (“sudo rasps-config”) did not work for me.

    • Nitin Bhandari says:

      Ya I agree with Patrick, it should be “sudo raspi-config”

  • Sydney Aldo says:

    ssh [email protected] worked for me

  • Kunsh says:

    Getting “Cannot currently show the desktop” after doing the above. Any suggestions of what we may be missing

  • Sneha says:

    Hello,
    I could not get the IP address of the RaspberryPi..!! I followed the same steps you have mentioned, still am unable to get it.

    • Varun Luniya says:

      Download Fing desktop app to view the ip address.

    • Noah says:

      an easy way to find it is to use:

      ping raspberrypi

      or ping raspi

      in either shell or cmd

  • Jules Fettu says:

    This was extremely helpful.
    Thanks!!!!

  • Jules Fettu says:

    On a side note:
    sudo apt install realvnc-vnc-server realvnc-vnc-viewer
    That command no longer works on Pi; however, this worked:
    sudo apt install realvnc-vnc-server

    thanks again!

  • Kadie says:

    This article literally saved me, thank you!

  • Jason says:

    This is really cool, however it doesn’t work with the new Raspberry Pi image installer as it makes the SD card read only. Is there a workaround so the config file and ssh folder can be added to the SD card?

  • Nick says:

    The title of your article suggests that you are connecting directly to a laptop LCD and not a full laptop via VNC. You may wish to clarify so people aren’t misled by search results.

  • Kuromegane says:

    I followed the steps to link my raspberry pi 400 to my laptop but I cannot control it because it doesn’t have a display.
    I just wanted to simply plug an HDMI cable between the keyboard raspberry pi 400 and my laptop but I guess it is not advanced yet.
    I researched about linking them with an ethernet cable and on my laptop it displayed something like unknown ethernet.
    Once I put the IP address of my keyboard raspberry pi 400 without a display on it because I just want to control it on my laptop. VNC viewer showed on a little window: ”Cannot currently show the desktop”.
    I wish they make a raspberry pi called over 9000 that can solve any of these technical difficulties.

  • Arash says:

    Dear Lydia,
    I can’t thank you more for your blog post. This is the only method that worked for me. I’ve been searching for a solution to my problem for at least 10 hours, and nothing just worked, but after reading this, I could successfully connect my Raspberry Pi 3B to my laptop monitor.
    You saved me!

  • AngelR says:

    brilliant!!!, it works. Thank you!

  • Brian says:

    Just wanted to post as I got stuck on trying to connect putty via SSH. I could see the Pi on my router but could not connect. Tried working thru all kinds of trouble shooting steps to get it connected.

    What finally worked was longing in and allowing the system to grab updates. I know that will not work out for those that don’t have an HDMI connection, but it’s the only thing that got this working for me.

    Also on the latest distro from raspberrypi.org VNC viewer was already installed so I just went straight to the setup step.

    Thank you for the great tutorial! Being able to connect like this makes working on my Pi much more appealing.

  • Comments are closed.