what’s the field before ssh-rsa in know_hosts on Raspbian GNU/Linux 9 (stretch)

ssh-gen by default creates a public key like

ssh-rsa AAAAB3NzaC1yc2E…6OEBTVwLRP1Ocyr user@DESKTOP-8BL3U5O

The Raspbian 9 has a different format

|1|dMpV8+ILjAAD11mhp57Q7hVk/4A=|pvCuzPyguQCwV9cN908uBz6CZLE= ssh-rsa AAAAB3NzaC1yc2E…6OEBTVwLRP1Ocyr

What is the field before ssh-rsa. How to generate it so id_rsa.pub can be inserted into know_hosts?

Use TPM 2.0 to automatically decrypt the SD Card in Raspbian OS

I’m a college student trying to complete the first part of a rather large project, but I’m new to TPM, and Linux. What I’m trying to do is have TPM handle automatic decryption of the root ext4 partition on the sd card upon boot. I have a Raspberry Pi 4 with Raspbian Buster installed. I’ve successfully encrypted the root already using this guide:

Raspbian Stretch Luks Encrypt

After that, I was able to type in a password at boot, so my next step was to try and automatically decrypt the sd card at boot with an Infineon TPM I have installed on the GPIO. My supporting software environment for the TPM includes tpm2-tools, tpm2-tss, and the tpm2-abrmd, and I can verify that all are working correctly.

I saw another post on stack exchange that mentioned using clevis along with the clevis-luks and clevis-tpm2 packages to accomplish this:

Use TPM2.0 to securely decrypt the hard drive in Linux — unattended

A contributor’s answer to the post suggested to try the clevis bind command. I went ahead and tried it myself, and the command executes without issue, but when I reboot, it seems the TPM is not handling the decryption as I am still prompted for a password.

I even found another guide that mentions using dracut with clevis-dracut so that the clevis module is loaded early, thus the sd card should automatically decrypt – assuming that the clevis module is communicating with the TPM to “unlock” the sd card, but that still hasn’t worked for me. That guide can be found here:

TPM Encryption in Fedora Linux

I realize it’s not Fedora I’m working with, but most of what’s in that guide should still apply. My question is, what am I doing wrong here? If there’s anyone that may be able to shed some light on my approach, I would greatly appreciate it.

Error “TypeError: Serial() takes no arguments” en Python (pySerial, Raspbian)

estoy intentando leer los bytes que entran mediante un usb (el cable que está enchufado en el usb es un conversor usb-serial232).

Yo no se mucho de python,y he estado buscando ayuda por internet hasta que me he encontrado con el siguiente código:

import serial ser = serial.Serial('/dev/ttyUSB0', 9600)  while True:     data = ser.readline()     if data:         print(data) 

Cuando ví esto me dio buenas vibraciones, ya que la forma que tengo de leer el mbus es con una librería de Linux que utiliza el ttyISB0.

La 1era vez que lo ejecuté me pedía que instalase la librería ‘serial’. Como estoy trabajando con PyCharm, con hacer Ctrl-Mayus-Intro se me instalaba sola.

Una vez instalé serial, me dio el error de ‘Serial’ (S mayúscula). Total, que lo instalé también.

Pero me sigue dando el siguiente error:

/root/PycharmProjects/prueba1/venv/bin/python /root/PycharmProjects/prueba1/file1.py Traceback (most recent call last):   File "/root/PycharmProjects/prueba1/file1.py", line 2, in <module>     ser = serial.Serial('/dev/ttyUSB0', 9600) TypeError: Serial() takes no arguments  Process finished with exit code 1 

Y ya no se que hacer, he estado mirando en internet, pero no hay nada sobre ese error.

Toda ayuda será bien recibida. Un Saludo

Could not install apache2 on Raspberry 3 B+ with Raspbian stretch, can’t find /etc/apache2.conf

I’m new to raspberry Pi, I just followed a tutorial to setup Raspberry pi 3 b+ with raspbian stretch OS. And I was trying to install apache2 with apt-get install apache2 the following error occurred:

apache2.service - The Apache HTTP Server    Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)    Active: failed (Result: exit-code) since Sun 2019-06-23 01:06:15 CDT; 51ms ago   Process: 26477 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)  Jun 23 01:06:15 raspberrypi systemd[1]: Starting The Apache HTTP Server... Jun 23 01:06:15 raspberrypi apachectl[26477]: apache2: Could not open configuration file /etc/apache2/apache2.conf: No such file or directory Jun 23 01:06:15 raspberrypi apachectl[26477]: Action 'start' failed. Jun 23 01:06:15 raspberrypi apachectl[26477]: The Apache error log may have more information. Jun 23 01:06:15 raspberrypi systemd[1]: apache2.service: Control process exited, code=exited status=1 Jun 23 01:06:15 raspberrypi systemd[1]: Failed to start The Apache HTTP Server. Jun 23 01:06:15 raspberrypi systemd[1]: apache2.service: Unit entered failed state. Jun 23 01:06:15 raspberrypi systemd[1]: apache2.service: Failed with result 'exit-code'. 

when cd to /etc/apache2 there’s no apache2.conf file or anything else. What should I do??

How To Install and Use A Plex Media Server On Raspbian Stretch

Plex is a media streaming application that allows you to keep your media collection – movies, music, photos – on a server attached to your local network and access them from a browser-based interface or app. Plex even streams a wide variety of podcasts and shows directly from the internet and by upgrading to the Premium (paid) tier Plex offers many more services. You can use the free version of Plex if you only want to view your own media and free to view streaming content.

In this guide, we will install Plex on a Raspberry PI minicomputer. Raspberry PI’s make grade Plex streaming servers because:

  1. They are low power and fan-less. You can leave them running 24/7 without worrying about your energy bills.
  2. They are sufficiently powerful to stream HD movies to your computer.
  3. They are full computers with a desktop environment so you can log and use GUI tools to manage them.
  4. They are $ 35 USD!

These reasons make a Raspberry PI an ideal home streaming server and a great introduction to using Linux if you haven’t already taken the plunge.

Requirements

You will need a few things to get your Plex server up and running. They are as follows:

  1. Raspberry PI 3 (any version).
  2. 16GB microSD card.
  3. Micro-USB Android phone charger (for the Raspberry PI).
  4. USB keyboard.
  5. HDMI monitor or TV to use a monitor.
  6. USB storage device which is large enough to hold your media.
  7. A Plex user account (optional). You will need to this to claim your Plex media server and lock it to your account with your user name and password. You can register a Plex user account (for free) at https://www.plex.tv/

You will use the keyboard and mouse to access the Raspberry PI during the installation and configuration. You will not need them later during normal use of Plex as we will configure the Raspberry PI be accessible via a VNC remote desktop connection.

Installing The Operating System

Your first job is to get the operating installed onto the microSD card that will hold the OS of the Raspberry PI. The operating system that we will install is Raspbian. Raspbian is based on the Debian operating system and compiled for the ARM CPU that the Raspbian uses.

Browse to the download page here and download the Raspbian Stretch with desktop image. This is a large, 1.1GB, file that you need to save to your computer. Do not unzip this file. The software we will use to flash it to the microSD card will do this for you.

If you are an experienced Linux user the command line instructions for flashing the Raspbian image are here

Everyone else needs to download and install the software that we will use to flash the microSD card – balenaEtcher. This software is a beautiful cross-platform (Windows, OSX, and Linux) application that flashes SD cards and USB thumb drives.

Note, you will erase any data on the microSD card in the next step so make sure you have a copy of any data on it before you proceed.

Insert your microSD card into your computer and start up balenaEtcher. The simple screen that you will see looks like this:

Click on the Select image button and browse to the Raspbian image you downloaded and select it. balenaEtcher will search for and automatically select the microSD card that plugged into your computer. Check that the size listed next to the device that balenaEtcher has selected is the same size as your micoSD card just to be sure you are using the right device.

When you are ready hit Flash!. It will take several minutes to flash the microSD card. When balenEtcher has finished remove the microSD card and load it into your Raspberry PI.

Plug the screen and keyboard into your Raspberry PI and then plug in the phone charger. The Raspberry PI will now power on. Log in with the following details:

  • Username – pi
  • Password – raspberry

Follow the first-boot, on-screen instructions until you get to the desktop.

You will need to open a terminal to continue the guide.

System Users and Groups

When you install Plex later in this guide a new system user will be created called plex. We are going to create this user now so that we can use it before we install Plex.

In the terminal you have open on the Raspberry PI run the following command to create the new user called plex:

sudo useradd plex 

This command will not create a home directory at /home/plex it will only add the user to the system. Now that plex exists we are going to add them to the users group. This will allow us to mount the USB storage device using the users group which will allow both plex and pi to read and write to the device.

The following command will add plex to the users group:

sudo usermod -a -G users plex 

Auto-Mounting The USB Device

Raspbian will always give the device name /dev/sda to the first USB device that you plug into the Raspberry PI. This allows us to create an entry in the file that configures device mounting, /etc/fstab, so that the USB you have your media on will always get automatically mounted at the same location.

Before you edit /etc/fstab you need to get the UID (User ID) of pi and the GID (Group ID) of users. First, get the UID of pi by running this command:

sudo grep "pi" /etc/passwd 

This will give output that looks like the following:

pi:x:1000:1000:,,,:/home/pi:/bin/bash 

pi‘s UID is the first number i.e. 1000. The following command will get the UID of users:

sudo grep "users" /etc/group 

This prints the output:

users:x:100:pi,plex 

The UID of users is 100. Using this information open /etc/fstab with a text editor. Here nano is used:

sudo nano /etc/fstab 

Add a line that has the following format:

/dev/sda1  /media/pi/Media  vfat  umask=0002,gid=<GID>,uid=<UID>  0  0 

Substituting the values we discovered earlier:

/dev/sda1  /media/pi/Media  vfat  umask=0002,gid=100,uid=1000  0  0 

You must use the values from your Raspberry PI.

Finally, we need to create the directory we have set as the mount point and change its user and group:

sudo mkdir -p /media/pi/Media sudo chown -R pi:users /media/pi sudo chmod -R 775 /media/pi 

Plug in your USB device and confirm that it has been automatically mounted at /media/pi/Media. You will be prompted to open a file manager when you plug in the USB device that will open to its mount point i.e. /media/pi/Media.

Installing Plex

Plex is not installable from the default Raspbian repositories. As a result, you will need to add the Plex repository and their APT signing key.

Add their APT key with the following command:

sudo wget https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add - 

Next, open a new APT sources file that will contain the address of the Plex repository:

sudo nano /etc/apt/sources.list.d/plex.list 

Add this line:

deb https://downloads.plex.tv/repo/deb public main 

Save and exit. Before installing new software a good policy is to first perform a system update. This will help avoid any installation errors. Run these two commands to get your Raspberry PI up to date:

sudo apt update sudo apt upgrade 

When they have completed install Plex with this command:

sudo apt install plexmediaserver 

Plex is now installed and ready to start serving media. You should, if you haven’t already done so, plug in your USB device that contains your media now.

Logging into Plex

Plex is now running and listening on the public IP address of the Raspberry PI. You will need to get the IP of the Raspberry PI so that you can log into Plex. In the terminal you have open run this command:

hostname -I 

The IPv4 IP address will be the first one listed. Take this IP address and create a URL that has the same format as the following one:

http://<IP>:32400/web/ 

Substituting <IP> with an example private network IP gives us the example URL:

http://192.168.0.2:32400/web/ 

Enter that into a browser on your computer on the same local network as your Raspberry PI.

Here, if you have signed up for a Plex account, you need to use those credentials to log into your Plex server. The Plex server will verify the user name and password with the Plex servers. You do not need to do this but not doing so will disable functionality including some security features.

Adding Your Media Library

During the initial login and setup you will be prompted to add your own media library with the following dialog:

You can also do this from the Plex desktop after the initial setup by clicking on the Add Library link in the side navigation panel.

When you click “Add Library” dialog box will open:

Choose the type of media on your USB device and change the name of the library by clicking on the Name field. Then click Next.

Now click on the BROWSE FOR MEDIA FOLDERS button on the page that follows:

This will open a new dialog:

Select the Media folder and click ADD. This is the folder we created to mount your USB cevice e.g. /media/pi/Media. Finally, confirm that this is correct by clicking the ADD LIBRARY button. All your media on the USB device will now appear on the Plex desktop and be ready to stream to any device on your local network.

Enabling The VNC Remote Desktop

VNC is an open source version of the Windows Remote Desktop Protocol. It enables a person to log into the desktop environment of a remote computer such as your Raspberry PI. When you have enabled VNC you will not have to use a keyboard and mouse to access your Raspberry PI’s desktop.

The default Raspbian image contains all the VNC components so you don’t need to install anything but you do need to enable it.

Open a terminal on the Raspbian desktop and enter the following command:

sudo raspi-config 

This will open a command line menu. Use the up and down arrows and enter to navigate the menus. Proceed as follows:

  1. Highlight Interfacing Options and hit enter.
  2. Highlight P3 VNC and hit enter.
  3. Hit enter for <Yes>.
  4. Confirm <OK>.
  5. Use the TAB key to highlight <Finish> and hit enter to exit the program.

You can now log into your Raspberry PI desktop using the VNC Viewer. Downland and install this application on your local computer and use the IP address of your Raspberry PI to log in as the pi user.

Adding New Media To Your Library

When you need to update the media on your USB device so that you have new movies or shows to watch there are two ways to get this done.

Moving The USB Device

The first method is to unplug the USB device from your Raspberry PI, plug it into your local computer, copy the data onto it and move it back.

The following procedure will ensure that you do not corrupt the data on the USB device.

  1. Log into your Raspberry PI’s desktop via the VNC Viewer application linked to in the Enabling The VNC Remote Desktop section.
  2. Shutdown the Raspberry PI.
  3. Unplug the USB.
  4. Plug the USB device into your local computer.
  5. Copy your data on the device.
  6. Eject or unmount the USB device.
  7. Unplug the USB device.
  8. Plug the USB device into the Raspberry PI.
  9. Unplug and plug back in the power cable to the Raspberry PI.

When your Raspberry PI boots up log back into Plex click on the three dots next to your Media Library then click on Scan Library Files. This will prompt Plex to review the contents of the USB device and add the new media files to your Library.

Copying Files Over The Network

Your Raspberry PI is connected to the local network so you can transfer your media to it over the network instead of manually moving the USB to your computer to copy the files.

The best program to get files securely from your Windows computer to the Raspberry PI is called WinSCP. Follow that link to download, install and open WinSCP.

WinSCP will open the following dialoge box:

Fill in the boxes as follows:

  • Host – Enter the IP of your Raspberry PI.
  • Username – Enter pi.
  • Password – Enter the password for user pi.

Click Save and create a bookmark for the Raspberry PI. Finally, hit Login to log into your Raspberry PI.

Use the address bar in the right-hand panel to navigate to /media/pi/Media:

You can create directories to organize your media in there and the Plex server will automatically index everything.

Accessing Your Media

In this guide, you have accessed your Plex with a browser from your local computer. You are also able to access your Plex server from your phone or tablet via the official Plex app. This link will install if for Android. If you are using an iPhone or an iPad search for “Plex” in the AppStore on your device.

Conclusion

You have now got a Raspberry PI installed and running as your Plex media server on your local home network. This article covered the basic installation and configuration to get a Plex up and running. Now that you have done that you should read some of the articles on the Plex website that cover how to get the most of your Plex server: https://support.plex.tv/articles/ .

 

The post How To Install and Use A Plex Media Server On Raspbian Stretch appeared first on Low End Box.

Raspbian: Copy new file from sdcard /boot to /home on startup

I have a custom configuration file that I would like to copy over during startup, preferably into /home/pi. I know how to copy the file via a systemd service, but the issue is that the file isnt visible in /boot. I am putting a file named environment.txt into the /boot directory (next to wpa_supplicant and ssh files) when the sd card is inserted into my computer, but when I put the card into the pi and ssh into it and look at the /boot directory, I dont see the config.txt file there.

What am I doing wrong? Is there a better way to do this? I know I can put the file in there manually but I would like to not have to ssh in to do so.

Thanks in advance!

Assign Static IP to the Raspberry Pi using ‘nmcli’ or any other tool on Raspbian Jessie-lite

I’m using Raspberry Pi 3 with Raspbian Jessie-lite. I want to assign Static IP to the Raspberry Pi using ‘nmcli’ or any other tool.

Raspbian Jessie-lite comes with wpa_supplicant and other networking tools. I have already used them but the problem is I have to restart the device when I connect to new Wi-Fi network or change assign static IP.

As a solution to the problem I used network-manager nmcli(0.9, higher versions are not available for jessie). But I cannot find a way to assign static ip details for Wi-Fi.

Making a command line program on linux (Raspbian or Ubuntu)

My objective is to make a program that can be installed and then operated using Terminal.

For example,

  1. Pip is installed
  2. We write pip install numpy in the terminal, and numpy is installed.

Challenges I’m facing:

  1. We write pip in terminal or command line and it understands what pip is. I can’t think of a way to get this done.

  2. Once the above objective is completed, I need to pass multiple arguments like instead of install numpy it will look like set color 4.

The language I’m working on is Python and the OS is Raspbian.

Unfortunately, I have no idea if there exists a terminology for such problems, feel free to edit.

What is a good simple way to check for and update a web-based trigger for a raspbian script

I’m trying to set up a script that can execute based on a simple change made somewhere that only I have control over on the web, so I can trigger an action remotely for an rPi watchdog-type script. The script is a csh script on raspbian. Key points there being; simple, my control only, web based.

I thought of using a tweet as the trigger, but using wget appealed to me as it’s a single line of code to get a timestamp, and changing a google doc is simple. I wouldn’t even have to make a specific change to the file, any change would update the timestamp.

So, I need help retrieving the timestamp from a My Drive file, or a better, simple solution to create a simple to update trigger. I’m open to suggestions.

Thanks in advance