Headless Raspberry Pi Setup
In order to get SSH'd into a new instance of a rasbian build raspberry pi we need to do 2 things; enable ssh and as of more recently we need to create a user as there is now longer a default 'PI' user.
Step 1: SSH
OK, firstly we can assume that we have already created our bootable SD card using the pi image tool (opens in a new tab). Now we need to navigate in our terminal to the SD card nd create the ssh file we mentioned earlier to enable ssh on first boot.
Mac
> cd /Volumes/BOOT > touch ssh
Windows
> dir <need to confirm mount location> > echo $null >> ssh
Step 2: User Account
Right, the next thing we need to do is create a user, as I mentioned this step was previously optional as there was a 'pi' user built into the image however, this is no longer the case for security reasons.
OK so we need a user name and password to get our ssh connection up and running, for the rest of this guide I will be using the following;
User: luke
Password: ChangeMe
OK, same as before we need to be in the root of the boot SD card, but this time we need to create a file called 'userconf' and add our user, nano is the easiest way to create and edit this file;
> cd /Volumes/BOOT > nano userconf
This will open an empty file with the nano text editor and we need to add the following, assuming the user name and password is the same as mine;
luke:$1$atYWG5rt$829ZFG8r2Lg8t8Ti.R0Of0
Now everything after the colon is the hash of the password 'ChangeMe' we decided on earlier, this hash is created with the following command which will return the hash as seen below;
> echo 'ChangeMe' | openssl passwd -1 -stdin $1$atYWG5rt$829ZFG8r2Lg8t8Ti.R0Of0
Note: I would recommend running this command in a second terminal tab or
window so youhave the hash to hand when you need it.
This final step is to save and close your userconf file, if your using nano then press 'ctrl c' and hit return.
Conclusion
So assuming that all went to plan you can eject your sd card, put it into the pi and boot and ssh into it, you will of cource need to find out the IP address of the PI but this can be done by checking the list of connected devices on your router before and then after the PI has booted, you should see a new device.