Headless Raspberry Pi

The following article will show you how to set up and access any Raspberry Pi without the need of a screen, mouse and keyboard (headless)The main pre-requisite is to set up the SSH protocol and the network interface (WIFI or Ethernet) in the Raspberry Pi following the next steps.

1. Configure a SSH protocol

Write an empty text file named “ssh” (no file extension) to the root of the directory of the eMMC. When it sees the “ssh” on its first boot-up, Raspbian will automatically enable SSH (Secure Socket Shell), which will allow you to remotely access the Pi command line from your PC.

 

2. Configure the network connection

To setup a Wi-Fi connection on your headless Raspberry Pi, create a text file called wpa_supplicant.conf, and place it in the root directory of the microSD card. You will need the following text in the file.

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
scan_ssid=1
ssid="your_wifi_ssid"
psk="your_wifi_password"
}

Change the country to “ES” for Spain or to another country code for a different country, and enter your actual SSID and password. Upon boot up, Raspbian will log you into that network. However, if you’re on a public Wi-Fi network that requires you to click “Ok” on a splash page before you get Internet, this method won’t work.

Prefer to use Ethernet? If you plug your Raspberry Pi directly to a wired network, you should be able to access it by its name (raspberrypi or raspberrypi.local) without changing any other files.

Direct ethernet connection

If your PC has a spare Ethernet port or you have an Ethernet-to-USB dongle, you can use a network cable to go directly from your Pi to your computer. Just make sure that you have Bonjour installed on your PC and SSH enabled on the Pi (see above). Then, you can just connect the two devices over Ethernet.

If you want the Raspberry Pi to get its Internet connection from your PC over the Ethernet port, you need to do the following in Windows 10.

1. Navigate to the Network Connections menu, which is part of the Control Panel. You can get to this screen by going to Settings->Network & Internet->Wi-Fi and then clicking “Change Adapter Settings” on the right side of the screen. This works whether you are sharing an Internet connection that comes to your PC from Wi-Fi or from Ethernet.

 

2. Right-click on the adapter that’s connected to the Internet, and select properties.

 

3. Enable “Allow other network users to connect” on the “Sharing” tab.

 

4. Select the Ethernet port that is connected to the Raspberry Pi from the “Home networking connection” menu, and click Ok.

 

Connecting via SSH

After you have the Pi connected to your network or directly to your PC, you’ll need to establish an SSH connection.

1. Download and install Puttyif you don’t already have it. Putty is the leading SSH client for Windows.

2. Enter raspberrypi or raspberrypi.local as the address you wish to connect to in Putty, and click Open. You usually need to add the .local if the Pi is directly connected to your PC via USB or Ethernet cable.

 

3. Click Ok if you get a security warning alert. It’s not a problem.

4. Enter pi as your username and raspberry as your password. You may want to change these later.

 

Enabling and Connecting over VNC

1. Enter sudo raspi-config at the command prompt.

 

A configuration app opens.

2. Select Interfacing Options (number 5 on the list)

 

3. Select VNC (number 3 on the menu)

 

4. Select Yes. 

 

5. Hit Enter to acknowledge the VNC server is enabled.

 

6. Select Finish

 

On your PC:

1. Download, install and launch VNC Viewer.

2. Select New connection from the File menu.

 

3. Enter raspberry.local in the “VNC Server” field. If this does not work, try again with the name “raspberrypi” without .local.

 

4. Click Ok.

5. Double-click on the connection icon to connect.

 

6. Click Ok if you are shown a security warning.

7. Enter the Pi’s username and password when prompted. The defaults are username: pi and password: raspberry. Click Ok.

Your Raspberry Pi desktop will then appear in a window on your main computer’s desktop. You’ll be able to control everything from there.

Sources:www.tomshardware.com