Install and configure SSH on Debian or Ubuntu

edafe.de/ssh

SSH is a protocol that enables secure connections over unsecured networks. It supports the use of asymmetric encryption for user authentication. Private keys are kept locally, while public keys are stored on the remote machine.

The following configuration disables root logins on the remote machine. Only users belonging to the group ssh-users may establish a connection. Access to the remote machine is tied to the local user’s private key.

In this example, the name of the remote machine is yourserver, which has the address 192.168.1.10 on the network. remoteuser is a user on yourserver, whereas localuser is a user on the local machine.

Begin by choosing an encryption passphrase to secure the private key that you will generate in Step 5.

On the remote machine

Step 1

Install the secure shell server on yourserver with the following command:

$ sudo apt install --yes openssh-server

Step 2

If you are using ufw as a host-based firewall

Configure ufw to allow connections to the secure shell server.

$ sudo -- bash -c 'ufw allow ssh && systemctl restart ssh.service'

If you are using firewalld as a host-based firewall

Configure firewalld to allow connections to the secure shell server.

$ sudo -- bash -c 'firewall-cmd --zone=public --add-service=ssh --permanent && firewall-cmd --reload && firewall-cmd --info-zone=public'

Step 3

Restrict access to yourserver to members of a specific group. Start by creating the group ssh-users.

$ sudo addgroup --system ssh-users

Add the user remoteuser to the group ssh-users.

$ sudo adduser remoteuser ssh-users

On the local machine

Step 4

Install the secure shell client with the following command.

$ sudo apt install openssh-client

Step 5

Generate a new key pair for the the user localuser:

$ cd ~/.ssh && ssh-keygen -t ed25519 -o -a 100

Save the key pair to the directory /home/localuser/.ssh/. Choose a name that facilitates easy identification.

Enter file in which to save the key (/home/localuser/.ssh/id_ed25519): id_ed25519-yourserver

The use of an appropriate passphrase to secure the private key is mandatory.

Step 6

Create the file ~/.ssh/config to configure the secure shell client.

$ nano ~/.ssh/config

Add the follwing minimal entry for the host yourserver.

Host yourserver
Hostname 192.168.1.10
IdentityFile ~/.ssh/id_ed25519-yourserver
IdentitiesOnly yes

Step 7

Deploy the public key with the following command.

$ ssh-copy-id -i ~/.ssh/id_ed25519-yourserver.pub remoteuser@yourserver

When prompted to confirm the authenticity of the host yourserver, type yes and press [Enter].

The authenticity of host 'debian-server (192.168.1.10)' can't be established.
ED25519 key fingerprint is SHA256:C9RxLLVbvFwVJc0L4JHzcuHQSaPHJZe/GrRDvqy6rAG.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

Step 8

Log into the remote machine.

$ ssh -i ~/.ssh/id_ed25519-yourserver remoteuser@yourserver

In the next step, enter the passphrase for your private key.

Enter passphrase for key '/home/localuser/.ssh/id_ed25519-yourserver':

Step 9

On the remote machine, download this configuration file to harden the ssh server. You are encouraged to inspect its contents.

$ sudo -- bash -c 'wget -P /etc/ssh/sshd_config.d/ --show-progress https://edafe.de/debian/sshd_config.conf'

Activate the modifications on the remote machine.

$ sudo systemctl restart ssh.service

Step 9

On the local machine, open a new terminal window and run the following command.

$ ssh -i ~/.ssh/id_ed25519-yourserver remoteuser@yourserver

In the next step, enter the passphrase for your private key.

Enter passphrase for key '/home/localuser/.ssh/id_ed25519-yourserver':

Display the active configuration for the remote ssh server and verify its settings, paying particular attention to options for maxauthtries, permitrootlogin and passwordauthentication.

$ sudo sshd -T

All done!

For more in-depth information, please see stribika’s post-Snowden advice on hardening OpenSSH server installations.

The book SSH The Secure Shell by Daniel Barrett, Richard Silverman and Robert Byrnes is still useful today and has information on other clever stuff you can do with SSH.

Install Syncthing for continuous file synchronisation on Debian or Ubuntu

Syncthing is an open source tool that synchronises files continuously across multiple devices. It transfers data between two or more of your computers, without uploading any information to the cloud.

Syncthing packages are available for Android, Windows, macOS and Linux (including Synology DSM). In addition, Synctrain enables iOS devices to “securely synchronise files with other devices that have Syncthing installed”.

The usefulness of the Syncthing Project cannot be overstated.

Running the Syncthing stable-v2 channel

Syncthing is included in the Debian and Ubuntu repositories, respectively. If you would rather use the most up-to-date version, you need to add the Syncthing repository to your list of APT sources.

These instructions are targeting the latest release of the Syncthing stable channel. In the following example, syncthinguser is the local username.

Step 1

Add the Syncthing release key for validation of packages downloaded from the Syncthing repository.

$ sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg

Step 2

Add the Syncthing repository.

$ echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable-v2" | sudo tee /etc/apt/sources.list.d/syncthing.list

Step 3

Install Syncthing on your system.

$ sudo -- bash -c 'apt update && apt install --yes syncthing apt-transport-https'

Step 4

Enable Syncthing for the local user syncthinguser. Don’t forget to replace syncthinguser with your username before running the command.

$ sudo -- bash -c 'systemctl enable syncthing@syncthinguser.service && systemctl start syncthing@syncthinguser.service && systemctl status syncthing@syncthinguser.service'

Step 5

You may need to edit your firewall settings to open ports for incoming and outgoing traffic.

If you are using ufw as a host-based firewall

Configure ufw to allow connections to Syncthing.

$ sudo ufw limit syncthing

If you are using firewalld as a host-based firewall

Configure firewalld to allow connections to Syncthing.

$ sudo -- bash -c 'firewall-cmd --zone=public --add-service=syncthing --permanent && firewall-cmd --reload && firewall-cmd --info-zone=public'

Step 6

Access the Syncthing configuration page by using your browser to navigate to the following address:

http://localhost:8384

Step 7

Complete your setup by referring to the Syncthing documentation.

Upgrading from the stable-v1 channel

If you have previously installed from apt.syncthing.net and are currently running Syncthing 1.x, upgrading to the stable-v2 channel is straightforward.

Remove the old APT sources configuration file.

$ sudo rm /etc/apt/sources.list.d/syncthing.list

Add the new repository for the stable-v2 channel together with its release key.

$ sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg && echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable-v2" | sudo tee /etc/apt/sources.list.d/syncthing.list

Upgrade to the latest stable version of Syncthing.

$ sudo -- bash -c 'apt update && apt upgrade --yes'

revWhiteShadow recently described the Syncthing 2.0 release as ‘A Giant Leap Forward in Decentralized File Synchronization‘.

GNOME shell tutorial: desktop workflow explained


Playing this video requires sharing information with Google. Read the privacy policy

“Before we get started, let me say this upfront: GNOME shell is not a traditional desktop and if you try to use it as one, you will not be very efficient.”

AJ Reissig

The Debian Administrator’s Handbook

“We wanted the book to be freely available (that is under the terms of a license compatible with the Debian Free Software Guidelines of course). There was a condition though: a liberation fund had to be completed to ensure we had a decent compensation for the work that the book represents. This fund reached its target of €25K in April 2012.” Raphaël Hertzog and Roland Mas hope that you will enjoy the book.

debian-handbook.info

Click to copy