Raspberry Pi / Setup / Basic Setup

Raspberry Basic Setup

By Marcelo Fernandes Aug 24, 2017

Basic Setup

Experience has shown that trying to work with Raspberry Pi only by terminal commands can be a really problematic process. In 2016 the raspberry team disabled the standard out-of-the-box ssh conection, and now, we have to manually set this config. It is considered to be a security improvement Reference.


Said that, the easiest way to set up raspberry is to selecting a Desktop img installation (one good tool to mount it is Etcher) and plugin-in a display and a keyboard/mouse. Once that is done, it's very easy to connect through the wifi connection and getting an IP address.
If you do not have a monitor and keyboard in order to configure your Pi, you can follow the step below, it's not so complicated, but it can change overtime, so check out the date of this post before following along.

[Optional] Configuring the Raspberry without a monitor

Ps: If you decide to configure your raspberry pi using a monitor or you already have a configured raspberry, skip to the step 2.


Once you got your Raspberrian (or any other distro) loaded in your SD Card, open the folder that corresponds to your SD Card (after a raspberrian installation it should be named "boot"), and create a file without extension called "ssh". Doing that, the raspberry already knows that it is allowed to connect via SSH. Easy right? The standard user and password are: pi/raspberry

After that, our raspberry needs to know which network it will connect. In order to do so, we need to create a wpa_supplicant.conf file with the following subject:


network={
    ssid="networkNAME"
    psk="networkPASSWORD"
}

Now you can jump to step 2

Step 1: Enabling SSH connections

Type in the command in raspberry terminal.

sudo raspi-config

Navigate to ssh and hit Enter and select Enable SSH

You can also do this prior booting your raspberry pi.
Every operational system that has access to the SD card (no matter if it is linux, macOs or Windows), is enabled to access the /boot/ folder, and in order to automatically enable the ssh prior the Raspian OS booting, we can create a file called ssh in this /boot/ directory. The content of this file does not matter, it will be deleted after the booting anyway, and hence, the SSH will be enabled.

Step 2: Getting the raspberry IP:

The easiest way is navigatin through the router interface and finding the connected devices. But, you can do it by typing some commands into the terminal as well:

Using nmap

# Install dependencies
sudo apt-get install nmap
# Get the subnet you are connected to
hostname -I
# Which gives me 192.168.0.103
# use the nmap command with the -sn flag (ping scan)
# on the whole subnet range
nmap -sn 192.168.0.0/24

Now get your raspberry address.

Step 3: Connecting to raspberry via SSH

Now it gets pretty straight forward:


# Connect via "pi" user. Its default password is "raspberry"
ssh pi@[ip_address]


Notes


References: