Enforce SSH or SCP password authentication

Use the bellow ssh/scp options in order to enforce password (keyboard-interactive) authentication:

ssh -o PubkeyAuthentication=no user@example.com
scp -o PubkeyAuthentication=no user@example.com

or

ssh -o PreferredAuthentications="password" user@example.com
scp -o PreferredAuthentications="password" user@example.com

How to connect without a password via ssh?

To connect without a password via SSH, you can use public key authentication. Public key authentication is a secure and convenient way to log in to a remote server without entering a password each time.

Here’s a step-by-step guide to setting up passwordless SSH authentication:

1. Generate SSH key pair: On your local machine, generate an SSH key pair if you haven’t already done so. Open a terminal and run the following command:

ssh-keygen -t rsa

This will generate a pair of keys: a private key (usually id_rsa) and a public key (usually id_rsa.pub).

2. Copy the public key to the remote server: Use the following command to copy your public key to the remote server you want to connect to:

ssh-copy-id username@remote_host

Replace username with your username on the remote server and remote_host with the hostname or IP address of the remote server. You will be prompted for your password on the remote server.

If the ssh-copy-id command is not available on your system, you can manually append the content of your public key (id_rsa.pub) to the ~/.ssh/authorized_keys file on the remote server.

3. Configure SSH on the remote server: SSH server configuration should allow public key authentication. On the remote server, open the SSH server configuration file (usually located at /etc/ssh/sshd_config) using a text editor.

Locate the line that starts with #PubkeyAuthentication yes and remove the leading # to uncomment the line. If the line doesn’t exist, you can add it.

Save the changes and exit the text editor.

4. Restart SSH service: Restart the SSH service on the remote server to apply the changes you made to the configuration file. The command to restart SSH depends on your operating system. For example, on Ubuntu, you can use:

sudo service ssh restart

Alternatively, you can use the following command if you are using a system with systemd:

sudo systemctl restart sshd

5. Test the passwordless SSH login: Try to SSH into the remote server without a password:

ssh username@remote_host

Replace username with your username on the remote server and remote_host with the hostname or IP address of the remote server. If everything is set up correctly, you should be able to log in without entering a password.

That’s it! You have successfully set up passwordless SSH authentication. Now you can log in to the remote server without typing your password each time.

NextCloud – Improve Images preview and reduce CPU load

Here’s a quick guide on how to improve images preview and reduce CPU usage of NextCloud while browsing your directories containing images.

First you’ll need to install the following NextCloud App: Preview Generator

Then you’ll have to run the following “occ” command in order to optimize the size of the generated thumbnails:

php ./occ config:app:set previewgenerator squareSizes --value="32 256"
php ./occ config:app:set previewgenerator widthSizes  --value="256 384"
php ./occ config:app:set previewgenerator heightSizes --value="256"
php ./occ config:system:set preview_max_x --value 2048
php ./occ config:system:set preview_max_y --value 2048
php ./occ config:system:set jpeg_quality --value 60
php ./occ config:app:set preview jpeg_quality --value="60"

Once the Preview Generator app has been installed and activated, execute the following “ooc” command:

php ./occ preview:generate-all

This will scan all of your files and will genarate thumbnails. You can add the above command to your nextcloud user’s cron to be executed every 10 minutes eg:

*/10 * * * * php /path/to/your/nextcloud/occ preview:generate-all

Enforce SSH Connections Alive

Here are a couple of option you have in order to keep the SSH connection alive

$ ssh -o ServerAliveInterval=60 <user>@<ip>

The above will instruct the ‘ssh’ client to sent “alive” packets every 60 seconds.

The following will set the same as default (by adding the option to your ssh client’s configuration file) for each ssh connection.

$echo -e "Host *\n\tServerAliveInterval 60" >> $HOME/.ssh/config

Traccar – fix “The write format 1 is smaller than the supported format 2”

systemctl stop traccar
mkdir /opt/FIXH2
cd /opt/FIXH2
wget https://h2database.com/h2-2019-10-14.zip
wget https://github.com/h2database/h2database/releases/download/version-2.0.206/h2-2022-01-04.zip
unzip h2-2019-10-14.zip
mv h2 ./h2.2019
unzip h2-2022-01-04.zip
mv h2 ./h2.2022
find ./ -name "*.jar"
cp -p /opt/traccar.4.13/data/database.mv.db /opt/FIXH2
java -cp ./h2.2019/bin/h2-1.4.200.jar org.h2.tools.Script -url jdbc:h2:./database -user sa -script backup.zip -options compression zip
java -cp ./h2.2022/bin/h2-2.0.206.jar org.h2.tools.RunScript -url jdbc:h2:./database_new -user sa -script backup.zip -options compression zip
cp ./database_new.mv.db /opt/traccar/data/database.mv.db
systemctl start traccar