All posts by texnic

Raspberry Pi-based home connection

I am starting up an attempt to create a connected home. Here I will record instructions for some less obvious (to me) actions, where I had to google for more than 2 minutes to succeed.

Set up headless Raspberry Pi

I want to use headless Raspberry Pi, that is no connected keyboard or screen. Connection will be done via SSH.

Create Raspbian SD

I only have an 8 GB micro SD card at hand, so I need the smallest image I can get without much hassle. Currently it’s Raspbian Stretch Lite (download page for the current OS version is here). Using the free Etcher, I burn the image to the SD card.

Enable SSH

To enable SSH connection, with the card still mounted in the Mac, create an empty file named ssh in the SD card root location.

Start up Raspberry

Connect power and network cable (not trying WiFi at the moment). Red and green LEDs (of Raspberry 3) should light up, then only the red one remains on (power on).

After a few moments (within a couple of minutes), the router map of connected devices shows “raspberrypi”, so I can get its IP address. In my case 192.168.1.12.

Connect to Raspberry

To connect via SSH: ssh pi@192.168.1.12. It will warn that the key is not known, and ask if I still want to connect. After confirming (I am relatively sure my home network is safe, so I am connecting to this Raspberry), it logs into the Linux CLI of Raspberry. Success!

Security

Raspberry immediately warns me that the default password should be changed using passwd. Other worthy security-related recommendations can be found here.

Time zone

I noticed that the time in Raspberry (command date) was correct but the local time zone was UTC. It can be set using sudo dpkg-reconfigure tzdata.

Grafana and InfluxDB

sudo aptget update
sudo aptget upgrade
sudo apt-get install influxdb
At this moment http://192.168.1.7:8083/ works!

Grafana for RPi can be taken from https://github.com/fg2it/grafana-on-raspberry/releases:

wget https://github.com/fg2it/grafana-on-raspberry/releases/download/v4.6.3/grafana_4.6.3_armhf.deb
sudo dpkg -i grafana_4.6.3_armhf.deb

 

The installer tells how to run grafana:

sudo /bin/systemctl start grafana-server

    At this moment http://192.168.1.7:3000 works (shows Grafana login page; use admin/admin to log in)

These two commands:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server

might enable auto-start.

Python

Install pip

sudo apt-get install python3-pip

Advertisements

Use Google Authenticator with Microsoft’s live.com

Two-step authentication is the technology to use everywhere as much as possible, to prevent identity and data theft. Many online services, including Dropbox, LastPass, Facebook, are using Google’s Authenticator app. It generates random time-dependent one-time codes that should be entered in the process of the two-factor authentication.

Microsoft’s live.com service also supports the 2-step authentication. However, by default Microsoft wants you to use its own app to generate the one-time codes. It does not make much sense to use it, if you are using Google Authenticator (GA) for all other services. Luckily, Microsoft is smart enough to support GA as well, just in a little hidden, even though simple, manner. Here is how to set it up:

  1. “Add a new identity verification app”
  2. Choose “Android”, press “Next”
  3. (If you now choose “Install the app from the Google Play Store.”, you’ll be offered to install a Microsoft app.) DO NOT DO IT.
  4. At the bottom, there is a line: “Android device not compatible? Try this app instead.” It is a link to the Google Authenticator. Click it.
  5. On the next page, a QR-code for Google Authenticator is shown. Scan it with “Set up account” function in Google Authenticator, verify the code and you are good to go.

Getting file checksum on Synology

cksum utility can calculate the file checksum using 3 different algorithms. The third one is the well-known CRC32.

  • CRC32 of a single file: cksum -o3 filename
  • CRC32 of all files in the current directory: cksum -o3 *

To verify the checksum in Windows, I recommend using HashTab. After installing it, just check the proerpties of a file and compare the CRC32 value returned by HashTab to the value calculated by cksum. Note that HashTab shows CRC32 as a hex number while cksum shows a decimal value; you can use an online converter to compare the two values.

Example (for some file on my Synology):

ds414> cksum -o3 mrr40320.JPG
946866417 14531 mrr40320.JPG

The first number returned by cksum is the CRC32 value, the second the file size in bytes.

Value returned by HashTab for this file is 387008F1 which is the same as 946866417 returned by cksum.

Does anybody know what the 1st and the 2nd algorithms of cksum are? 

Synology command line interface

  • Control Panel: User: activate admin account, make sure you know the password.
  • Control Panel: Terminal & SNMP: activate SSH
  • Download Putty (link), a popular terminal client for Windows.
  • Run Putty and enter the Synology IP address without the port, choose connection type SSH. The port will be set automatically by Putty.
  • Press Open. Putty will ask if you want to trust the Synology key. Press yes (make sure your network is safe, otherwise your admin password may be compromised).
  • Synology should ask for login and password. Use admin and the corresponding password.

Additional info:
http://techanic.net/2014/04/12/configuring_ssh_and_scp_sftp_on_dsm_5.0_for_synology_diskstations.html.

Torrent for legal download

A lot of people associate torrents and pear-to-pear (P2P) technology in general with illegal music, film, and software downloads. Some internet providers even block the torrent protocol claiming that it’s illegal to use it.

Next time they do it with you, tell them: P2P is fully legal, and a lot of digital material can be downloaded via torrent. The advantage of using P2P instead of the direct download links is that reduces the load on the company server and may even help get the file quicker while also helping others. Be internet ecology-friendly.

I will be collecting here examples of what you can legally download via p2p. Please feel free to contribute in the comments.

Some sites also specialize on freely distributable material:

See also:

OSMapping

Useful links for OpenStreetMap beginners