# Connecting a Raspberry Pi to a local network

## Configuring network access <a href="#configuring-network-access" id="configuring-network-access"></a>

If your Pi is connected to the network via an ethernet cable, you can skip this section. Unless manually changed, our device will be available on the network under the default hostname `raspberrypi.local`.

Insert the SD card into your computer and create a file called `wpa_supplicant.conf` at the root of the boot volume of the SD card (e.g. `/Volumes/boot` on macOS). Paste the following:

```
country=COUNTRY
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="<Your wifi network name>"
    psk="<Your wifi network password>"
    scan_ssid=1
    key_mgmt=WPA-PSK
}
```

Do not forget to update the `ssid` and `psk` keys.

{% hint style="info" %}
COUNTRY should be set the two letter [ISO/IEC alpha2 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) for the country in which you are using your Pi, e.g.

* GB (United Kingdom)
* FR (France)
* DE (Germany)
* US (United States)
  {% endhint %}

{% hint style="info" %}
`key_mgmt` should be set according to your `psk`. If your network is protected by a WEP key, leave this field empty.
{% endhint %}

If you’re looking for more details about this step, please refer to the [Official Raspberry Documentation](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md).

## Enabling SSH <a href="#enabling-ssh" id="enabling-ssh"></a>

In order to access your Pi via SSH, you need to enable SSH. To do so, add an empty file, called `ssh`, at the root of the boot volume on your SD card (same location as `wpa_supplicant.conf` from the previous step).

## Accessing the Pi <a href="#accessing-the-pi" id="accessing-the-pi"></a>

Eject the SD card from your computer, and insert it into the Pi. It will take roughly 20 seconds to boot. You can then access your Pi from your computer via SSH using the following command from a console prompt:

```
ssh pi@raspberrypi.local
```

The default password is `raspberry`.

If you are unable to connect, make sure your computer is connected to the same network as your Pi, as specified earlier in `wpa_supplicant.conf`.

## Changing the hostname <a href="#changing-the-hostname" id="changing-the-hostname"></a>

If you wish to name your device something else than `raspberrypi`, in particular if you have several Pi devices on your local network, you may change the hostname by running `raspi-config` from your Pi:

```
(pi) sudo raspi-config
```

Go to the “Hostname” menu, type in the desired name, for instance `raspi-basement`, and reboot. Next time you want to access your Pi via SSH, use the new hostname instead of `raspberrypi`, appended with `.local`:

```
ssh pi@raspi-basement.local
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://snips.gitbook.io/tutorials/t/troubleshooting-and-support/connecting-a-raspberry-pi-to-the-local-network.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
