From 1f0a3b84f219dec6b45f134cd424481526434569 Mon Sep 17 00:00:00 2001 From: Mark Tyers Date: Tue, 6 Aug 2019 16:24:24 +0100 Subject: [PATCH 1/2] added ssh password free login --- 01 Getting Started.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/01 Getting Started.md b/01 Getting Started.md index 0434d24..19c8ed1 100644 --- a/01 Getting Started.md +++ b/01 Getting Started.md @@ -131,3 +131,34 @@ pi@doej:~ $ If you are using Windows 10 you will need to download the [Putty](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) application. After launch you need to enter the hostname and user credentials in the appropriate boxes. Once logged in, Putty behaves like a standard terminal window. If the credentials are correct you are now connected to the server and all the commands you enter will be run on it. To quit and return to your computer enter the `exit` command. + +## 5 SSH Login Without Password + +Now we have enabled remote login we will finish by setting up ssh access that won't prompt you for your password! To do this you will need to complete the following steps (Only tested on MacOS and Ubuntu): + +The first step is to check your local computer (the one you will be connecting from) to see if you have a pair of authentication keys. These will be in a hidden directory called `.ssh` located in your home directory. + +```shell +$ test -f ~/.ssh/id_rsa ; echo $? + 0 +``` + +A non-zero value indicates an error so, if the command returns `1` you will need to generate the keys: + +``` + ssh-keygen -t rsa +``` + +Accept all the default options (keep pressing the enter key). + +Now copy the contents of the `id_rsa.pub` file to the clipboard. On MacOS you can use the command `pbcopy ~/.ssh/id_rsa.pub`. On linux display the contents of the file using `less ~/.ssh/id_rsa.pub` then select and copy. + +Now log into the Raspberry Pi and create a file called `authorized_keys`: + +```shell +nano ~/.ssh/authorized_keys +``` + +In the nano editor paste in the public key from your local computer then save (`ctrl+O`) and quit (`ctrl+X`). + +If you log back out the raspberry pi then try logging in again you will not be prompted for the password! From c6014316db29f28c7aa230751369ec9d96c546b1 Mon Sep 17 00:00:00 2001 From: Mark Tyers Date: Wed, 7 Aug 2019 13:14:45 +0100 Subject: [PATCH 2/2] added services intro --- 01 Getting Started.md | 8 +++--- Managing Services.md | 63 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 Managing Services.md diff --git a/01 Getting Started.md b/01 Getting Started.md index 19c8ed1..618cc77 100644 --- a/01 Getting Started.md +++ b/01 Getting Started.md @@ -4,10 +4,10 @@ In this worksheet you will be shown how to setup and configure a raspberry pi as a central 'hub' for your home automation system. By the end of this you will have: 1. The operating system (Debian Stretch Lite) installed on the hub. -2. The I2C interface configured for use (and a small display attached). -3. A working MQTT broker installed (but not fully secured!). -4. The latest versions of Python and Pip. -5. A NodeJS runtime environment for running scripts. We will then use this to publish a simple API. +2. The wireless interface configured to connect to the Internet. +3. The ability to connect securely over SSH from a remote computer without entering a password. +4. Changed the host name of the computer +5. Changed the password on the default user account. ## 1 Installing the Operating System diff --git a/Managing Services.md b/Managing Services.md new file mode 100644 index 0000000..4eba7d2 --- /dev/null +++ b/Managing Services.md @@ -0,0 +1,63 @@ + +# Managing Services + +A lot of the software you will be installing, such as [MySQL](https://www.mysql.com) will need to run as background services. This tutorial will guide you through how to install and manage background services. + +## 1 System D + +https://www.linuxjournal.com/content/initializing-and-managing-services-linux-past-present-and-future + +### 1.1 Installing Neo4J + +In this section you will be shown how to install and run a Neo4J instance using SystemV. + +## 2 Docker + +You can use the [Docker Playground](https://labs.play-with-docker.com) to learn how to work with Docker. + +## 3 Homebrew (MacOS Only) + +Until now all the tools and techniques covered work on the Raspberry Pi or indeed any computer running a [Debian](https://www.debian.org) based [Linux](https://www.linux.org) distribution (such as [Ubuntu](https://ubuntu.com) or [Raspberian](https://www.raspbian.org)). If you are using a [Mac](https://www.apple.com/uk/mac) (and [MacOS](https://www.apple.com/uk/macos)) for your development work you should make use of the [Homebrew](https://brew.sh) package manager which provides commands to install, uninstall, update and run a wide range of software packages. + +### 3.1 Installation + +The installation instructions can be found on the main [website](https://brew.sh), in summary you need to run the following in the terminal app which uses the [Ruby](https://www.ruby-lang.org/en/) language: + +```shell +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +### 3.2 Installing Packages + +Once Homebrew has been installed you can use it in the terminal to install a wide range of software, for example to install MySQL: + +1. Search for the software on the [Homebrew website](https://formulae.brew.sh/formula/mysql). This tells you the correct software name, in this case it is `mysql`. +2. Now we can install the software using `brew install mysql`. + +### 3.3 Starting and Stopping Services + +Many of the software packages run as background services and we need to be able to start, stop and restart these. The easiest way is to install the [Homebrew Services](https://github.com/Homebrew/homebrew-services) using `brew tap homebrew/services` command. The `tap` subcommand allows you to access other repositories that are not included in Homebrew's master repository. + +Once the services are installed you can list the installed services and see if they are running using the following command: + +```shell +$ brew services list + Name Status User Plist + mosquitto stopped + mysql stopped + neo4j stopped +``` + +Now we can start and stop the services: + +```shell +$ brew services start mysql + ==> Successfully started `mysql` (label: homebrew.mxcl.mysql) +$ brew services restart mysql + Stopping `mysql`... (might take a while) + ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql) + ==> Successfully started `mysql` (label: homebrew.mxcl.mysql) +$ brew services stop mysql + Stopping `mysql`... (might take a while) + ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql) +```