Corporate Blog | BETWEEN Technology

How to set up a server with a Raspberry PI

Escrito por IT Solutions de BETWEEN | 10-jul-2019 6:27:19

In the last post we talked about the technological step forward that has been made with Edge Computing, and this time we will delve into how to set up a server with Raspberry Pi. You are ready?

In recent years, companies have begun to invest a large part of their budget in cost savings, and in the case of technology companies, in efficiency and electricity consumption above all. From studying the most sophisticated technologies to knowing how to set up a server with a Raspberry Pi. This type of practice allows us to make improvements in the business environment, reducing fixed costs, such as electricity consumption. Many IT infrastructure companies have taken a turn towards a more 'green' infrastructure, aware that saving on energy entails a significant reduction in economic costs.

What is a Raspberry Pi?

Raspberry Pi is a low-cost small motherboard computer (85 x 54 mm) developed in the United Kingdom by the Raspberry Pi Foundation. The foundation's original objective was to promote the teaching of computer science and programming in the field of education.

They cost less than €40 and this, along with their low consumption, has meant that in just 5 years more than 12 million units have been sold.

Raspberry Pi Models

Model A

The first Raspberry model. It began shipping in 2012. It is based on a single core 700Mhz processor and 256MB of RAM. It has no Ethernet port and a USB Wi-FI adapter is necessary to connect it to the internet. It has HDMI, RCA Video, 3.5mm Jack Connector, 1 USB and 1 MicroUSB (used for power).

 Model B and B+

A variant on the Model A launched in 2012 that features several improvements. There is double the RAM (512MB), as well as an Ethernet connector and an additional USB.

The Model B + was added later, and this has 4 USB ports and changes from using SD to MicroSD.

Raspberry Pi 2 Model B52​

Launched in 2014, it includes a new QuadCore processor with 900Mhz and 1GB of RAM. It keeps the 4 USB ports but does away with the RCA connection.

Raspberry Pi 3 Model B

Launched in 2016, it features a 1.20GHz Quad-Core and 1GB of RAM. The most significant new development is the inclusion of Wi-Fi and Bluetooth (4.1 Low Energy).

Model B+

This model appeared in March 2018. It includes a new 1.4Ghz processor, includes dual band WiFi (2.4Ghz and 5Ghz), the network card is now 300Mbits/s and Bluetooth 4.2 (Low Energy) is included.

Model A+

It was announced in November 2018. The A+ models have fewer features and cost less. In Spain it sells for approximately €30 and has 256 MB of RAM, only 1 USB port and it does not include ethernet.

Advantages of Raspberry Pi

Raspberry Pi, even though it is a board created for purposes of dissemination and study, allows for a variety of projects. This is because even with its limited features it is capable of running complex systems, offering a wide range of possibilities. These are some of the strengths of the Raspberry platform:

  • Low consumption (at full power less than 2W)
  • Low cost. The Raspberry Pi 3b+ costs under €40 and the microSDs where we will install the system are priced between €7 and €15 depending on the storage capacity.
  • Multitude of possible projects. Because it is based on a Debian distribution, we can carry out different types of projects according to our needs.
  • Small size. Thanks to its tiny size (85 x 54mm), it can be installed in multiple sites, such as behind a TV screen.

Possible projects with Raspberry Pi

One of the advantages of Raspberry Pi is the multitude of projects and potential developments that we can carry out on its platform. Apart from its original use - to learn how to program - it can be used for projects where we require reduced power, but it rewards low power consumption. For example:

  • Advanced media centre
  • Video surveillance system
  • Email server
  • VPN server
  • DNS server
  • Apache web server + PHP
  • JS web server
  • ownCloud
  • Monitoring system on Nagios

What we need to create our Raspberry Pi server

For our current project, creating a mini server with SSH, FTP and SMB access, we need:

  • A Raspberry :D
  • A class 10 microSD, with a minimum of 8GB (in order to install the operating system)
  • A mobile charger to power the Raspberry (if we have not bought one with the Raspberry)
  • A HDMI cable
  • A USB keyboard
  • A desire to tinker J

Installing Raspbian on Raspberry Pi

The first thing we have to do after buying a Raspberry Pi is to download the operating system from https://www.Raspberrypi.org/downloads/ so as to install it on our microSD.

There are two operating system versions available to us: Raspbian and NOOBS. The latter is aimed at simpler installation. In our case we will use Raspbian, which is based on a Debian distribution. Within Raspbian there are three versions: Raspbian Stretch with desktop and recommended software, Raspbian Stretch with desktop and Raspbian Stretch Lite.

We do not want a graphic environment for our server so we will download Raspbian Stretch Lite

Once the operating system is downloaded, we will install it on the microSD using the Etcher tool. Etcher is an Open Source tool that allows us to install an image on an SD/micro SD card.

Select the file with the image that we have previously downloaded:

We select the disk drive that corresponds to our micro SD card:

Finally we click on the 'Burn!' button to start recording the image on the SD:

At the end of the process, Etcher automatically verifies that the copy was successfully completed. Once finished, insert the microSD in the Raspberry Pi, connect an HDMI to the screen, connect a USB keyboard to it and turn it on.

Customise Raspberry Pi configuration

Once the Raspberry Pi has booted, we will see a Linux console or terminal. To start configuring the Raspberry we write the following in the terminal:

sudo raspi-config

This will open a graphic environment with several options for configuring our Raspberry. Let's look at the most important ones:

“configure_keyboard – Set keyboard layout”

To configure the keyboard, you have to go through several steps:

The most usual type of keyboard is “Generic 105-key (Intl) PC”

Now let's look at the language we will use with the keyboard. By default it is set to British English. Go to "Other" and move using the arrow keys until we come to the "Spanish" option.

Next, you will be asked what language the keyboard is in (in addition to the one we told it we were going to use in the previous point). We might be using a Spanish keyboard with the "Ñ" or an English keyboard, even if we are writing in Spanish. Most commonly the keyboard will also be "Spanish".

Next let's look at the location of the "Alt" key. The common thing to do is to accept “The default for the keyboard layout”.

Then it will ask for the "AltGr" compose key. Likewise, the usual thing to do is to use "No compose key".

The last thing to select is whether or not we want to use the key combination "Ctrl + Alt + Delete" to exit the graphical interface mode. By default, the option is set to NO.

“change_pass – Change password for ‘pi’ user”

By default Raspbian has created the user 'pi' with the default password 'Raspberry'. We can change this from the menu. Obviously, this option is highly recommended.

Once the option has been selected, the system will ask us to enter the new password.

If we have correctly entered the new password, the following message will appear:

“change_locale – Set locale”

Change the Raspberry's local and region settings. By default it is set to en_GB. We will change it to es_ES.

“change timezone – Set timezone”

Change the time zone to that of your country, in our case es_ES.

 

“ssh – Enable or disable ssh server”

We will activate ssh so as to be able to connect remotely (via terminal) to our Raspberry Pi

We can now connect to our Raspberry through ssh.

For this we can use the Putty software (https://www.putty.org/)

PuTTY is an SSH and Telnet client with a Free license. It is available for Windows and Unix and a version for Mac OS and Mac OS X is in development.

We just need to enter the IP of our Raspberry and then when asked, our username and password.

 

“update – Try to upgrade raspi-config”

With this option, our Raspberry's operating system will be updated as well as all its supporting features.

Configure Raspberry Pi network

 

An important first step for our server is to be able to set a fixed IP for our Raspberry.

To configure a static IP in Raspian we need to edit the /etc/dhcpcd.conf file using the command

sudo nano /etc/dhcpcd.conf

The following file will open. The part to add is the one at the end:

interface eth0

static ip_address=192.168.1.240/24

static routers=192.168.1.1

static domain_name_servers=8.8.8.8

Save the changes using "Ctrl + O" and press Enter. "Ctrl + X" closes the configuration file.

From this moment on, our Raspberry will always have IP 192.168.1.240

Install vSFTPD in Raspberry PI in order to have an FTP server

FTP is a protocol for transferring files between client and server, very commonly used for the exchange of files, such as, for example, for a web server.

To install the application we open our terminal and type:

sudo apt-get install vsftpd

Once installed, we go to the configuration file to modify certain parameters:

sudo nano /etc/vsftpd.conf

In this file we need to change the value of local_enable and write_enable.

local_enable=YES

write_enable=YES

The vsftpd.conf file should look like this:

# Run standalone vs. from an inetd start daemon from an initscript.

listen=YES

## Disallow anonymous FTP.

anonymous_enable=NO

## Allow local users to log in.

local_enable=YES

## Allow per-user configuration for local users.

user_config_dir=/etc/vsftpd_user_conf

## Enable FTP write commands – controlled with cmds_allowed list.

write_enable=YES

We now just need to restart the service of our FTP server with the following command:

sudo service vsftpd restart

We are now ready to make our first connection from our FTP client. To do so, you can use FileZilla or whatever one you prefer.

The details to get connected are the same ones we use to connect via SSH to our Raspberry Pi - username "pi" and our password. The only difference is that we have to set our IP in the following manner: sftp://192.168.1.240.

To test the connection we can download the FileZilla software:

 

Once these steps have been completed we can use our small Raspberry Pi to share files via FTP. In the next posts we will look at how to share resources within a Windows network using the SMB protocol as well as how to secure our Raspberry.