create account

Raspberry Pi Server - Part 0: Setup and ssh access by lynor

View this thread on: hive.blogpeakd.comecency.com
· @lynor ·
$0.02
Raspberry Pi Server - Part 0: Setup and ssh access
======================================

This is first part of a series for people who ever would like to experiment with server systems, or always wanted to setup their own cheap Linux server at home. Raspberry Pis are not reliable enough for production systems, but they are good enough to get experience with Linux systems and deployment of tiny web services and web sites.

Please feel free to comment.
Enjoy!

======================================

# Setup your Raspberry Pi to be used via SSH

For this you will need following hardware:
1. Raspberry Pi (I use a Raspberry Pi 3 Model B with a clear case and heat sinks)
2. MicroSD (I use a 32GB SanDisk)
3. Micro USB Power Source (5V, 2.5A should do)
4. Ethernet Cable 
5. Peripherals for one time setup: Keyboard, Mouse, Screen and HDMI-cable

And following software:
1. Jessie lite image (https://www.raspberrypi.org/downloads/raspbian/)
2. Win32diskimage (http://www.raspberry-projects.com/pi/pi-operating-systems/win32diskimager), or any other imager
3. git bash (install git from https://git-scm.com/downloads)

## Preparations: Get your Raspberry Pi ready

First, we need to setup Raspbian on our Pi. Get the Jessie Lite image from  https://www.raspberrypi.org/downloads/raspbian/

![Jessie_Lite.PNG](https://steemitimages.com/DQmfPfDuFHRquzxd77bJoAfrSZvAw46ta7NnFLoYJiVPV9X/Jessie_Lite.PNG) 

There are several software solutions for write an image to an SD card. I used the win32diskimager.

![1_diskimager.PNG](https://steemitimages.com/DQmYLoso8oWNMXW2WvCEF5f9uhCFwaWjR9fhFBfZSbxJXuF/1_diskimager.PNG)

Run the imager, and carefully select the drive you want to write your image to and the jessie lite image you just downloaded from the raspberrypi site.

(Hint: In case you would like to set up multiple Raspberry Pis in the same way, the diskimager also can read an image. Once your raspberry pi is set up completely, you can make a backup of it, and even write the same image on multiple new MicroSD cards, when can then be used in other Raspberry Pis)

Once the image is written to your MicroSD card, safely eject your MicroSD card and insert it into your unpowered Raspberry pi.


![IMG_20170628_224822_small.jpg](https://steemitimages.com/DQmWK5yWFuTsX3FRMvPbs7XPPWS2jbi9ZFFFB36sCZ2GdWd/IMG_20170628_224822_small.jpg)

![IMG_20170628_224846_small.jpg](https://steemitimages.com/DQmXmWMte5TadtyMstTzH8SwkN83kTkJfXRjpUaniZp6S9B/IMG_20170628_224846_small.jpg)

I got a clear case for my raspberry and some heat sinks


## Starting up the Raspberry Pi for the first time

Plug in all peripherals (screen, mouse, keyboard) and power up your Raspberry Pi.

After the starting up process, you will be greeted with the login prompt:

![login_small.jpg](https://steemitimages.com/DQme2kDogTA67FfVwgRXyr9KYXUc2NFQRnaHj3YLQLBLNTh/login_small.jpg)

The default login is:
user: pi
password: raspberry
(Hint: Watch out for keyboard language settings)

Once we are logged in successfully, we get the next prompt:
![first_login_success_small.jpg](https://steemitimages.com/DQmbnd3xiDhaE13eKvBFgR12AshgcFAEB19mNbdQYYgRaWH/first_login_success_small.jpg)

Now we can get started to change the configurations of the Raspberry Pi.

## Setting the Pi's configurations

### Expand Filesystem 

The first thing we will change is to make sure that the entire SD card is available to the OS.

to enter the configurations menu, type:

`sudo raspi-config`

now choose: **Advanced Options**
and finally: **Expand Filesystem**

![](https://steemitimages.com/DQmPzj4zwjHwYcC2nUixuaA79LedBD1vTZvnMoNE5NMipfr/image.png)

Once you finished, you will be informed that the filesystem will be resized upon the next reboot.
Finish with OK, we still have some settings to set.

### Enable SSH

Next, we will enable remote access to the raspberry via SSH.
For safety reasons SSH is disabled by default, so we will have to change that.

choose: **Interfacing Options**
and: **SSH**

Here you can enable SSH for our Raspberry Pi, which we will need in future.


### Change password

Finally we will set a new password to our raspberry pi, just to make sure nobody can access the pi account.

choose: **Change User Password**

The `pi` user is a `Sudoer`, which means it can call commands with root permission. In the wrong hands, this could be abused to turn our nice Raspberry Pi `Sudoer` user into an `Evildoer` machine. (Bad joke, sorry)
More information about Linux users can be found here:
https://www.raspberrypi.org/documentation/linux/usage/users.md


Once these three changes are done, shutdown your raspberry pi with following command:
`sudo shutdown -h now`


## Connect to Router and first SSH login

### Physically connect your Raspberry Pi to the Router

Now take your Raspberry Pi, you can unplug all cables and peripherals.
You will only need your Ethernet cable and your Micro USB Power supply.

Go to your router, connect your Raspberry Pi via Ethernet and start it up by plugging in the power supply.

From this point on, we should not need to touch our Raspberry Pi ever again physically if things go right.

### Find the Raspberry on the Network

To ssh into our Raspberry Pi, we need to find out its IP address, and there are several ways to find it.
I recommend installing **git**, which will allow us to use **git bash** in the future.
Also, in the future we would like to have our own private git repository on our little server.

I prefer to use `nmap` for it.

`nmap` is an available command in **git bash** by default. After installing git, right click anywhere in a directory and run **git bash**.


Now check your standard gateway, this is the ip address of your router. Mine is 192.168.0.1, so I will use nmap to look for all devices connected in this network with:
`nmap -sP 192.168.0.0/24`

Among other devices, it also shows my Raspberry Pi at the address **192.168.0.136**

![FindRaspberryIp.PNG](https://steemitimages.com/DQmY2BM8F73BHENKGapfqJaeRrbXYKtCjQmfvfC4sLuqSE2/FindRaspberryIp.PNG)

### Login via SSH

After finding out the IP Address, we can login to our Raspberry via SSH:
`ssh pi@192.168.0.136`

This means that we will login as the user pi.

At your first login attempt, you need to confirm the authenticity of the host:
![Raspberry_first_login_athenticity_host.PNG](https://steemitimages.com/DQmbcf9GyYDGwiYhTkgVnF6qDtCsayJkhRyaaRGmxMwMBmm/Raspberry_first_login_athenticity_host.PNG)

Now your git bash terminal is your terminal to the Raspberry Pi', and you can give commands which will be executed by the Raspberry Pi.

In case you did not change the password, you will see a warning, and this is the time when you really should choose a new password for the `pi` user.

For today, this is how far we go.

To finish the ssh connection, you can simply type:
`CTRL`+`D`
or just type:
`logout`

![Raspberry_Logout.PNG](https://steemitimages.com/DQmbHGkBDrzxu7vQ8roAgQEG8QU6aQNqbBh3cjm9g3BCvz5/Raspberry_Logout.PNG)

This will close the connection, and your **git bash** will turn back to normal.

Next time I will go through the process of generating ssh keys, disabling password login to have a somewhat safe way to open the raspberry to the outside world, so we can ssh to our Raspberry Pi Server from anywhere, anytime.
👍  , , ,
properties (23)
authorlynor
permlinkraspberry-pi-server-part-0-setup-and-ssh-access
categoryit
json_metadata{"tags":["it","homeserver","technology","raspberry","ssh"],"image":["https://steemitimages.com/DQmfPfDuFHRquzxd77bJoAfrSZvAw46ta7NnFLoYJiVPV9X/Jessie_Lite.PNG","https://steemitimages.com/DQmYLoso8oWNMXW2WvCEF5f9uhCFwaWjR9fhFBfZSbxJXuF/1_diskimager.PNG","https://steemitimages.com/DQmWK5yWFuTsX3FRMvPbs7XPPWS2jbi9ZFFFB36sCZ2GdWd/IMG_20170628_224822_small.jpg","https://steemitimages.com/DQmXmWMte5TadtyMstTzH8SwkN83kTkJfXRjpUaniZp6S9B/IMG_20170628_224846_small.jpg","https://steemitimages.com/DQme2kDogTA67FfVwgRXyr9KYXUc2NFQRnaHj3YLQLBLNTh/login_small.jpg","https://steemitimages.com/DQmbnd3xiDhaE13eKvBFgR12AshgcFAEB19mNbdQYYgRaWH/first_login_success_small.jpg","https://steemitimages.com/DQmPzj4zwjHwYcC2nUixuaA79LedBD1vTZvnMoNE5NMipfr/image.png","https://steemitimages.com/DQmY2BM8F73BHENKGapfqJaeRrbXYKtCjQmfvfC4sLuqSE2/FindRaspberryIp.PNG","https://steemitimages.com/DQmbcf9GyYDGwiYhTkgVnF6qDtCsayJkhRyaaRGmxMwMBmm/Raspberry_first_login_athenticity_host.PNG","https://steemitimages.com/DQmbHGkBDrzxu7vQ8roAgQEG8QU6aQNqbBh3cjm9g3BCvz5/Raspberry_Logout.PNG"],"links":["https://www.raspberrypi.org/downloads/raspbian/","http://www.raspberry-projects.com/pi/pi-operating-systems/win32diskimager","https://git-scm.com/downloads","https://www.raspberrypi.org/documentation/linux/usage/users.md"],"app":"steemit/0.1","format":"markdown"}
created2017-07-02 16:29:21
last_update2017-07-02 16:29:21
depth0
children4
last_payout2017-07-09 16:29:21
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,200
author_reputation1,619,972,702
root_title"Raspberry Pi Server - Part 0: Setup and ssh access"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id7,033,984
net_rshares3,470,469,840
author_curate_reward""
vote details (4)
@adutetrup ·
$0.45
Excellent write!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 71 others
properties (23)
authoradutetrup
permlinkre-lynor-raspberry-pi-server-part-0-setup-and-ssh-access-20170726t025650331z
categoryit
json_metadata{"tags":["it"],"app":"steemit/0.1"}
created2017-07-26 02:55:18
last_update2017-07-26 02:55:18
depth1
children0
last_payout2017-08-02 02:55:18
cashout_time1969-12-31 23:59:59
total_payout_value0.399 HBD
curator_payout_value0.050 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length16
author_reputation3,887,745,101
root_title"Raspberry Pi Server - Part 0: Setup and ssh access"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id9,743,057
net_rshares124,672,328,434
author_curate_reward""
vote details (135)
@wallaceme ·
$0.10
properties (23)
authorwallaceme
permlinkre-lynor-raspberry-pi-server-part-0-setup-and-ssh-access-20170708t145040077z
categoryit
json_metadata{"tags":["it"],"app":"steemit/0.1"}
created2017-07-08 14:51:39
last_update2017-07-08 14:51:39
depth1
children2
last_payout2017-07-15 14:51:39
cashout_time1969-12-31 23:59:59
total_payout_value0.090 HBD
curator_payout_value0.012 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation1,396,120,544
root_title"Raspberry Pi Server - Part 0: Setup and ssh access"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id7,760,296
net_rshares23,399,901,012
author_curate_reward""
vote details (23)
@lynor ·
Thanks!

Maybe i should write a description how to make bots leaving 2 word comments on posts they find.
And maybe, as a follow up, how to make bots which upvote each other's 2 word posts.

What do you think?
properties (22)
authorlynor
permlinkre-wallaceme-re-lynor-raspberry-pi-server-part-0-setup-and-ssh-access-20170710t203141977z
categoryit
json_metadata{"tags":["it"],"app":"steemit/0.1"}
created2017-07-10 20:31:42
last_update2017-07-10 20:31:42
depth2
children1
last_payout2017-07-17 20:31:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length208
author_reputation1,619,972,702
root_title"Raspberry Pi Server - Part 0: Setup and ssh access"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,028,735
net_rshares0
@qed ·
Ja, also ich hab mich jetzt schon viel mit den Botmöglichkeiten gespielt, und es gibt tatsächlich viele und die machen auch schnell viel reputation mit solchen "thank you's". Ich kann nicht einschätzen wie "detremental" das für die Platform ist, weil es gibt hier ja schon sowas wie ne community, aber es wird glaub ich mit der Zeit nicht besser werden. Hab jetzt in den letzten 10 Tagen jeden Tag was kurzes gepostet, aber bin nicht sicher ob man nicht momentum erreichen kann - wenn das das ziel ist - ohne recht weit runter zu gehn in Sachen lowest denominator. Die programmiercommunity (tags "programming" und "steemdev") ist denk ich, vermutlich, guten Willens, aber noch zu klein.
properties (22)
authorqed
permlinkre-lynor-re-wallaceme-re-lynor-raspberry-pi-server-part-0-setup-and-ssh-access-20170711t222855878z
categoryit
json_metadata{"tags":["it"],"app":"steemit/0.1"}
created2017-07-11 22:28:57
last_update2017-07-11 22:28:57
depth3
children0
last_payout2017-07-18 22:28:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length686
author_reputation371,686,564,844
root_title"Raspberry Pi Server - Part 0: Setup and ssh access"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,161,996
net_rshares0