SSH configuration in Raspberry Pi

Enabling default SSH access

In order to enable SSH access after downloading Raspbian Lite without desktop environment and writhing it to SD card you must add empty file called ‚ssh‚ (no extension) on boot drive while your SD card is still connected to your PC. Next place the SD card in your Raspberry Pi and boot.

Login to Raspberry Pi using SSH connection

In command line type with your Raspberry Pi IP address:


and provide default password raspberry

Change default password

Change password using this command:


Configure password less SSH access

First make sure that you have keys generated for your client (PC). If you using Cmder on Windows 10 check following directory for files id_rsa and


Next copy the public key


Disable logging with password

For security reasons it is better to disable asscess with password and use only key dependent authentication, so edit the ssh configuration file:

sudo nano /etc/ssh/sshd_config

Find line

#PasswordAuthentication yes

remove comment (# character) and change value to no

PasswordAuthentication no

Now restart the service or reboot the Raspberry

sudo /etc/init.d/ssh restart
sudo reboot

Changing SSH port

This is an optional step, you can change the default port from 22 to something else by editing SSH config file:

sudo nano /etc/ssh/sshd_config

change the port 22 to something else and restart SSH service as in previos

Port 50022

Next restart the ssh service

sudo service ssh restart

Start ssh agent on local machine

eval $(ssh-agent)


Configuring Samba on Raspberry Pi, to share USB drives

Today it is time to use Samba for USB Drives sharing.

Mounting USB Drive

1. Create new directory where your drive will be mounted

sudo mkdir /media/usbHDD
sudo chmod 744 /media/usbHDD

2. List your storage devices and save UUID of your drive

ls -l /dev/disk/by-uuid/

(Update) more readable command:

sudo blkid

3. Mount that drive to /media/usbHDD, use proper user and group (uid, guid), adjust drive path

sudo mount -o uid=pi,gid=pi /dev/sda1 /media/usb

4. Edit fstab

sudo nano /etc/fstab

and add line with UUID of your drive

UUID=18A9-9943 /media/usbHDD vfat auto,nofail,noatime,users,rw 0 0

5. Verify if drive is mounted

ls -l /media/usbHDD

restart and verify if drive is mounted after reboot

sudo reboot now
ls -l /media/usbHDD

If you have problems with auto mount you may need to install:

sudo apt-get install exfat-fuse
sudo apt-get install ntfs-3g

You may also need to change partition type in command in fstab file from vfat to ntfs

Installing Samba

The process of installation is very simple

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install samba samba-common-bin

Czytaj więcej

Useful commands on Raspberry Pi

In this post I’ll gather all useful commands that I used during my experiments with RPi


Lists all attached bulk storage devices


List all drives by uuid

ls -l /dev/disk/by-uuid/

Mount drive

sudo mount -o uid=pi,gid=pi /dev/sda1 /media/usb 

you have to use uid and gid in order to delete add new devices.

Automount drive at start-up

sudo nano /etc/fstab

and add

UUID=18A9-9943 /media/usb vfat auto,nofail,noatime,users,rw 0 0

The “nofail” option allows the boot process to proceed if the drive is not plugged in. The “noatime” option stops the file access time being updated every time a file is read from the USB stick. This helps improve performance.
Czytaj więcej

Install latest Java 8 on raspbian

I’m always looking for this commands when I need to install latest Java 8 JDK on my RPi, so I’m adding them here just in case I’ll need to use them again.

Unfortunately default Raspbian repository contains old Java version 1.8.0_65-b17 while the latest (when I’m writing this post) is 1.8.0_151-b12.


First install dirmngr:

 sudo apt-get install dirmngr

Second add deb repositories and key:

echo "deb trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver hkp:// --recv-keys EEA14886

Warning! If you add xentail repositories (as many RPi forums and other pages state) you’ll end up with old 1.8.0_65 version, you must be using trusty repositories in order to install latest Java version.

Update repositories:

sudo apt-get update

Install Java installer:

 sudo apt-get install oracle-java8-jdk 

Verify Java version

To be 100% sure I have proper version of Java I use basic command:

java -version

Remove old Java

In case you have old Java 8 JDK

sudo apt-get remove --purge oracle-java8-jdk


Remove Java
Default Java installation
trusty repositories of Java 8 JDK

Monitor Raspberry Pi 3 temperatute while stress

Basically I wanted to test how fast my RPi will heat up under stress with or without heat sinks

How to perform stress test

It is easy with stress application.


sudo apt-get install stress 

Stress test:

sudo stress --cpu 4

it will span 4 processes that will execute on each of RPi core calculating sqrt function (source).

Constantly measure CPU temperature


watch -n 1 /opt/vc/bin/vcgencmd measure_temp

This command will print cpu temperature on console each 1 second.

CPU utilisation

You can observe how 4 stress processes are utilising cpu with command:


Radiator tests

Cheapest small aluminium radiators under 0.24$ per lot: link

No heat sinks:

  • idle: around 50 C
  • under stress: up to 82 C
  • response on air flow: low decreases maximum temperature by 2-3 C

With heat sinks:

  • idle: around 44 C
  • under stress: up to 77 C
  • response on air flow: good decreases maximum temperature by 7-8 C


I’m a bit disappointed with those small heat sinks, expecting that they’ll lower temperatures more drastically. Using fan that will blows air on them will give better results.

Custom microUSB power cord for raspberry pi 3


During my first plays with Raspberry Pi 3 I wanted to have a flexible ways of powering my board with different power supplies.

There are two ways to power Raspberry Pi 3:

  • using micro USB socket – the best way, but you have to use charger with mounted micro USB male plug at the end of power cable. The RPi is also protected by fuse and power protection circuit.
  • Using GPIO pin header – easy to power from a variety of different power supplies using standard 2.54 mm female connector. Unfortunately this connections (GPIO2 and GPIO4) are bypassing 5V protection circuit and fuse, so using this pins carries a certain amount of risk of breaking your RPi.

I bought an industrial power supply Mean Well MDR-20-5 with 3.0A output,
so I needed to make my own power cable to power my PRi that will use power protection circuit on board.

Required hardware

So I bought:

RPi 3 consumes up to 750mA when under stress (source) and can power USB devices with 1.2A (source). Suggested power supply should be rated with 2.5A.

22 AWG wire should be good for powering RPi, because it can handle up to 7A (Maximum amps for chassis wiring parameter form table)


First thing is to find a micro USB male pinout (source):

Micro USB male connector pinout

2 D-
3 D+
4 ID

Now It is easy, just soldering pin 1 and 5 to power cable.

But STOP, do not power the PRi yet, you should test If  wires are soldered correctly.


Use any multimeter  with continuity testing feature.

First connect new power cable to RPi.

Second connect one multimeter probe to your 5V wire end and test continuity with second probe on:

  • first pin of micro USB female socket on RPi
  • test points PP1 and PP2

Third connect one multimeter probe to your GND wire end and test continuity with second probe on:

  • fifth pin of micro USB female socket on RPi
  • test points PP3, PP4, PP5 and PP6

RPi 3 top view

RPi 3 bottom view


RPi 3 power consumption

American Wire Gauge current limits

Micro USB male connector pinout

Raspberry Pi 3 test points