KKMIN

Booting up a long-forgotten device

Recently, after decluttering my room, I saw a box tucked in a dusty corner that caught my eye; after inhaling a chockful of dust and coughing my lungs out, I realized that it was the Raspberry Pi package I had bought 2 years ago!

Truth be told, I bought it back then not knowing what I was going to do with it, intending to experiment with it. Somehow, setting it up slipped my mind, and it has been faithfully waiting for me while gathering dust. I figured now would be the time to set it up; better late than never!

It seems I had already assembled the Raspberry Pi in its case as well as its external cooling fan, so all that was needed was to install the Raspberry Pi OS. The kit I bought came with an SD card that had NOOBS installed, so I simply needed to plug it in and install.

Unfortunately, after finishing the OS installation (or so I thought), I was greeted with an error that said the Firmware could not be found. (!) Most likely, the SD card had been corrupted after 2 years of lying in the dust.

Thankfully, re-writing an image to the SD Card was simple due to Raspberry Pi Imager, and the Pi was able to boot with no issues.

Enabling SSH

One of my first priorities was to enable SSH on the Pi so that I was able to control and use the Pi on my laptop/PC without connecting the Pi to an external monitor. I had to drag out and clean an old un-used monitor from the house to set this up, so SSH was of utmost priority.

Setting up SSH Keys

Once I have SSH set up, the next thing I did was to set up SSH keys for better security; using an SSH key pair ensures that only devices that has the SSH private key will be able to authenticate into the Raspberry Pi.

I used PuTTY as I was running a Windows machine and its pre-bundled tool PuTTYgen to create the SSH key pair. While the key file generated is only for use with the PuTTY client, PuTTYgen conveniently provides an option to convert it into OpenSSH keys, which was very helpful.

Host name and shortname troubles

When I tried to SSH into the Pi from the windows terminal, I noticed something strange. "ssh raspberrypi" (raspberrypi is the default hostname for the Pi) attempted to log in as "min@raspberrypi", but there was no such user called "min"! I had set my user name as "kkmin" in the Pi.

This was very strange; using PuTTY yielded no issues whatsoever. Inspecting the users in my Pi also showed that there was no "min" user present, only "kkmin". At this point, there was probably no need to panic as "min" was my own name after all, just a little strange.

After some digging, I found that the default username that is used for SSH is actually the shortname for the machine you are connecting from. So the shortname of my Windows machine was "min", which is why it was attempting to log into a non-existent user (and failing, of course).

The solution was to define a file "~.ssh\config" and put your desired connection configuration for a particular host, in this format:

Host <Your Host Name>
HostName <Actual host address>
User <Username>

Note that the field names can be a little misleading: Host is the shortform alias to connect to the host of your choice, and HostName is the full IP address / link itself.

Disabling password authentication

The last thing to do is to disable password authentication so that only users with the private key can SSH into the Pi. This was as simple as changing a "yes" to "no" in "/etc/ssh/sshd_config" inside the Pi.

Closing Thoughts

It took me about half a day's worth of time to get everything set up, but it was well worth the satisfaction of getting something off my to-do list. The next steps, of course, is to start some projects with the Pi. Watch this space!

← Back to home

Comments