Raspberry Pi First Steps

 · 3 mins read

Update: This article is outdated! The old Debian Squeeze image is no longer available. Please use the new Raspbian Wheezy image instead.

I had some free time today so I played with my brand new Raspberry Pi. Here is what i have done so far using the Debian Squeeze image.

1) Install the Vim text editor

To install my favorite text editor:

sudo apt-get install vim

2) Changing the localization, the keyboard layout and the timezone

To change the localization:

sudo dpkg-reconfigure locales

To change the keyboard layout:

sudo dpkg-reconfigure keyboard-configuration

To change the timezone:

sudo dpkg-reconfigure tzdata

3) Disable the overscanning

Overscanning is the black frame around the four edges of the video image. To disable the overscanning you need to create a text file config.txt on your boot partition /boot an put in the following text:

disable_overscan=1

4) Install bash autocompletion

First you need to install the bash completition:

sudo apt-get install bash-completion

Then you need to activate it by changing the file /etcbash.bashrc. First you need to open it with a text editor:

sudo vim /etc/bash.bashrc

And remove the hashtags # from the beginning of the following lines:

# if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#     . /etc/bash_completion
# fi

5) Reconfigure the OpenSSH server

The SSH server in the Debian Squeeze image is deactivated by default which is good for security reasons. The password for the user pi and the ssh private keys are available in the public. You can start it with the following line:

sudo /etc/init.d/ssh start

5.1) Activate SSH boot by default

To activate the ssh server at boot simply rename the file boot_enable_ssh.rc to boot_rc on your boot partition:

sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc

5.2) Create new SSH keys

Delete the old ones:

sudo rm /etc/ssh/ssh_host_*key

And create new keys:

sudo dpkg-reconfigure openssh-server

5.3) Change the SSH port

Changing the ssh port will stop many automated attacks and will add a little bit security though obscurity. To change the port of the SSH server you need to edit the file sshd_config with a text editor:

vim /etc/ssh/sshd_config

Edit the line which states Port 22 and change the number to a port not currently used on the system

# What ports, IPs and protocols we listen for
# Port 22

to e.g.:

# What ports, IPs and protocols we listen for
# Port 50633

And restart SSH:

/etc/init.d/ssh restart

6) Create a new user and remove the user pi

First we activate the root account by creating a password for the user root:

sudo passwd

Now you need to close all sessions and re-login as root.

Because of some configuration error the user pi has been created twice. So we need to manually delete one. Open the file passwd with a text editor:

vim /etc/passwd

And delete the line:

pi:x:1001:1001::/home/pi:/bin/bash

Now we can delete the user pi and his home directory:

deluser —remove-home pi

And add a new user:

adduser username

Set the groups:

usermod -aG adm,dialout,cdrom,audio,plugdev,users,lpadmin,\
admin,sambashare,vchiq,powerdev username

Try to login with the new username and password and try to get sudo. If this works disable the root account:

passwd -l root

7) Update the system and the firmeware

To update the system:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

To update the firmeware:

create a root shell:

sudo -s

install the git certificates:

apt-get install git-core ca-certificates

Download the update script to /usr/bin and set the excecutable flag:

wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update \
&& chmod +x /usr/bin/rpi-update

Excecute the update script:

rpi-update

Reboot the raspberry pi:

reboot


WRITTEN BY

Sebastian Glahn is a Senior Software Engineer living in Cologne. He writes about Software Development, 3D-Printing, Robots and other stuff. He is also a maintainer of several open source projects.

about | github | twitter