Skip to content

Commit da8c659

Browse files
committed
GH-109 Added security and access details to readme.
1 parent aadea98 commit da8c659

File tree

1 file changed

+78
-1
lines changed
  • _blog/running-k8s-cluster-on-pi-a-step-by-step-guide

1 file changed

+78
-1
lines changed

_blog/running-k8s-cluster-on-pi-a-step-by-step-guide/README.md

+78-1
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,85 @@ IPADDR=192.168.137.51
188188
IPADDR=192.168.137.52
189189
```
190190

191-
### Security
191+
### Security & Access
192192

193+
The steps in this section are optional but highly recommended.
194+
195+
#### Change the default Password.
196+
197+
I recommend to change the default `SSH` password from `raspberry` to something more unique and secure. To do so, first ssh into the first RPi device using the default password
198+
199+
```
200+
201+
```
202+
203+
Then enter the `passwd` command, your current password and type in the new password. Type it again for confirmation.
204+
205+
Repeat the above for the other RPi devices.
206+
207+
#### Change the `hostname`
208+
209+
Furthermore, for a more organised workflow, I change the `hostname` of each device so that when I `ssh` into them, I can see which Node I'm working with. As detailed in the above sections, I have a key name for each RPi device and I ultimately want to have the following:
210+
211+
|Key|Role|Description|IP Address|Hostname|
212+
|:-:|:--:|:----------|:---------|:------:|
213+
|MN1|Master|Kubernetes Master Node|192.168.137.50|learnk8s-mn1|
214+
|WN1|Worker|Kubernetes Worker Node|192.168.137.51|learnk8s-wn1|
215+
|WN2|Worker|Kubernetes Worker Node|192.168.137.52|learnk8s-wn2|
216+
217+
To change the `hostname`, for each RPi device, `ssh` into it, now using the new password.
218+
219+
```
220+
221+
```
222+
223+
Then edit the `hostname` using the preinstalled `nano` editor:
224+
225+
```
226+
sudo nano /etc/hostname
227+
```
228+
229+
Change `raspberrypi` to `learn8s-mn1`. Furthermore, we need to update the `hosts` file:
230+
231+
```
232+
sudo nano /etc/hosts
233+
```
234+
235+
Add change `raspberrypi` to `learn8s-mn1` at last line of the file. The last line should look like this:
236+
237+
```
238+
127.0.1.1 learnk8s-mn1
239+
```
240+
241+
Finally, `sudo reboot` the RPi device.
242+
243+
Repeat this foe the other RPi devices.
244+
245+
#### Passwordless SSH access
246+
247+
For more secure access to your RPi devices and also to avoid having to type in the `ssh` login password every time you want to `ssh` into a device, you can configure `ssh` to use your public `ssh key`. Assuming you have a public `ssh key` located in `~/.ssh` on your host machine, you can copy it into your RPi devices.
248+
249+
First access the first RPi using your password:
250+
251+
```
252+
253+
```
254+
Then create a `.ssh` directory using the following command to ensure the permissions are correct:
255+
256+
```
257+
cd ~
258+
install -d -m 700 ~/.ssh
259+
```
260+
261+
With the `.ssh` directory set up, go back to your host machine and enter the following command to copy the key into the first RPi:
262+
263+
```
264+
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
265+
```
266+
267+
Enter your password and you're done. If you try to `ssh` into RPi one more time, you should be automatically authenticated.
268+
269+
Repeat the above for the other RPi devices.
193270

194271

195272
### Installing Docker

0 commit comments

Comments
 (0)