• Zur Hauptnavigation springen
  • Skip to main content
  • Zur Hauptsidebar springen
  • Zur Fußzeile springen
Logo

CITROWEB Webdesign

Erste Wahl für Ihren Onlineauftritt

  • Home
  • Leistungen
    • Webdesign, Webentwicklung und Beratung
    • Online-Shops mit WooCommerce
    • Technische Unterstützung für WooCommerce-Shops
    • Suchmaschinenmarketing
      • SEO: Ihr Webauftritt erhält mehr relevante Besucher
      • SEA: Suchmaschinenwerbung für Ihren Webauftritt
    • Webhosting
  • Blog
  • Kontakt aufnehmen

Blog

How to remove WordPress Dashicons in frontend?

24. September 2022

Dashicons is the official WordPress icon font introduced with WordPress 3.8. The style file dashicons.min.css is loaded in the frontend, which is unnecessary for most pages. It is needed in the backend for the dashboard icons.

If you do not use dashicons on your pages or posts. Then you can disable the loading of the file. This will improve the performance of your site.

Here we present a small snippet that you need to place in your function.php file. This will remove the dashicons stylesheet from the frontend on your page. In the WordPress administration everything works with it as before.

/** Remove Dashicons for non logged in users **/
add_action('wp_print_styles', 'cw_remove_dashicons', 100);

/** Remove Dashicons stylesheet beeing loaded for not admin login pages **/
function cw_remove_dashicons()
{
    if (!is_admin_bar_showing() && !is_customize_preview()) {
        wp_dequeue_style('dashicons');
        wp_deregister_style('dashicons');
    }
}

That’s it! This should increase the performance of your website.

Kategorie: Performance, WordPress

Wie lassen sich Dashicons im WordPress-Frontend entfernen?

24. September 2022

Dashicons ist die offizielle WordPress-Symbolschrift, die mit WordPress 3.8 eingeführt wurde. Die Styledatei dashicons.min.css wird im Frontend geladen, was für die meisten Seiten unnötig ist. Es wird im Backend für die Dashboard-Icons benötigt.

Wenn Sie keine Dashicons auf Ihren Seiten oder Beiträgen verwenden. Dann können Sie das Laden der Datei deaktivieren. Das wird die Leistung Ihrer Seite verbessern.

Hier stellen wir Ihnen ein kleines Snippet vorstellen, das Sie in Ihrer function.php-Datei platzieren müssen. Damit wird auf Ihrer Seite das Dashicons-Stylesheet aus dem Frontend entfernt. In der WordPress-Administration funktioniert damit alles nach wie vor.

/** Remove Dashicons for non logged in users **/
add_action('wp_print_styles', 'cw_remove_dashicons', 100);

/** Remove Dashicons stylesheet beeing loaded for not admin login pages **/
function cw_remove_dashicons()
{
    if (!is_admin_bar_showing() && !is_customize_preview()) {
        wp_dequeue_style('dashicons');
        wp_deregister_style('dashicons');
    }
}

Das wars! Damit dürfte die Performance Ihrer Website gesteigert werden.

Kategorie: Geschwindigkeit, WordPress

How to Set Up SSH Keys on Ubuntu 22.04

17. September 2022

SSH (Secure Shell) is a cryptographically secured protocol used to manage and communicate with servers. If you are working with an Ubuntu server, you will probably spend most of your time in a terminal session connected to your server via SSH.

In this guide, we will focus on setting up SSH keys for an Ubuntu 22.04 installation. SSH keys provide a secure way to log in to your server and are recommended for all users.

Step 1 – Create the key pair

The first step is to create a key pair on the computer:

ssh-keygen

Current versions of ssh-keygen generate a 3072-bit RSA key pair by default, which is secure enough for most use cases (you can optionally specify the -b 4096 option to generate a larger 4096-bit key).

After entering the command, you should see the following output:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/your_username/.ssh/id_rsa):

Press Enter to save the key pair in the .ssh/ subdirectory in your home directory, or specify an alternate path.

If you have previously created an SSH key pair, you may see the following prompt:

/home/your_username/.ssh/id_rsa already exists.
Overwrite (y/n)?

If you choose to overwrite the key on disk, you will no longer be able to authenticate with the previous key. Be very careful when selecting „Yes“, as this is a destructive operation that cannot be undone.

You should then see the following prompt:

Enter passphrase (empty for no passphrase):

Here you can optionally enter a secure passphrase, which is highly recommended. A passphrase is a password that is requested when the key is used. It provides an additional layer of security.

You should then see output similar to the following:

Your identification has been saved in /home/your_username/.ssh/id_rsa
Your public key has been saved in /home/your_username/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:8STVn6r5nq+ABwWRlnsDaf0Ailrv4K6f5CTrEKREmyB username@hostname
The key's randomart image is:
+---[RSA 3072]----+
|+o. ++o          |
|oA . +..         |
| o   .+          |
|+    ..  .       |
|o    .o.A.  .    |
| .  o .Xo. o     |
|o.=. o .= +      |
|oO.+  .  = o     |
|*=*.o   oo=o.    |
+----[SHA256]-----+

You now have a public and a private key that you can use for authentication. The next step is to place the public key on your server so that you can log in using SSH key authentication.

Step 2 – Copy the public key to your Ubuntu server

The fastest way to copy your public key to an Ubuntu host is to use the ssh-copy-id utility. Due to its simplicity, this method is highly recommended, if available of course. If ssh-copy-id is not available to you on your client machine, you can use one of the two alternative methods described in this section (copying via password-based SSH or copying the key manually).

Copying the public key with ssh-copy-id

The ssh-copy-id tool is included by default in many operating systems, so it should be available on your local system. For this method to work, you must already have password-based SSH access to your server.

To use the tool, specify the remote host you want to connect to and the user account you have password-based SSH access to. This is the account to which your SSH public key will be copied.

For this we use the following command:

ssh-copy-id username@remote_host

The following message is output:

The authenticity of host '130.5.7.121 (130.5.7.121)' can't be established.
ECDSA key fingerprint is ea:ad:e4:A7:77:ff:13:24:e2:25:00:da:6e:d1:12:ae.
Are you sure you want to continue connecting (yes/no)? yes

This means that your local computer does not recognize the remote host. This is the case when you connect to a new host for the first time. Type „yes“ and press ENTER to continue.

Next, the utility will search your local account for the id_rsa.pub key we created earlier. If it finds the key, you will be prompted to enter the password for the remote user’s account:

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
username@130.5.7.121's password:

Type the password (your input will not be displayed for security reasons) and press ENTER. The utility connects to the account on the remote host using the password you specified. It then copies the contents of your ~/.ssh/id_rsa.pub key to the authorized_keys file in the ~/.ssh home directory of the remote account.

You should see the following output:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'username@130.5.7.121'"
and check to make sure that only the key(s) you wanted were added.

Now your id_rsa.pub key has been uploaded to the remote account. You can now proceed to step 3.

Copying the public key with SSH

If the ssh-copy-id command is not available but you have password-based SSH access to an account on your server, you can upload your keys using a traditional SSH method.

To do this, we use the cat command to read the contents of the SSH public key on our local computer and forward it to the remote server via an SSH connection.

On the other hand, we can make sure that the ~/.ssh directory exists under the account we are using and has the correct permissions.

Then we can pipe the content we transferred to a file called authorized_keys inside that directory. We will use the >> redirect symbol to append the content instead of overwriting it. This way we can add keys without destroying previously added keys.

The complete command looks like this:

cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"

The following issue follows:

The authenticity of host '130.5.7.121 (130.5.7.121)' can't be established.
ECDSA key fingerprint is ea:ad:e4:A7:77:ff:13:24:e2:25:00:da:6e:d1:12:ae.
Are you sure you want to continue connecting (yes/no)? yes

This means that your local computer does not recognize the remote host. This is the case when you connect to a new host for the first time. Type „yes“ and press ENTER to continue.

You should then be prompted to enter the password for the remote user account:

username@130.5.7.121's password:

After you enter your password, the contents of your id_rsa.pub key are copied to the end of the authorized_keys file of the remote peer’s user account. If this was successful, proceed to step 3.

Manual copying of the public key

If you do not have password-based SSH access to your server, you will need to perform the above process manually.

We manually append the contents of your id_rsa.pub file to the ~/.ssh/authorized_keys file on your remote machine.

To view the contents of your id_rsa.pub key, type the following on your local computer:

cat ~/.ssh/id_rsa.pub

You will see the contents of the key, which should look something like this:

ssh-rsa AAAAB4NzaC2yc2EAAAADAQABAAABgQC0YsVakZH8GBkHFBYmg8eeJX5LrFH7y8PHmLJDMGYvdnKSoASzo5zKKgzTVveEe82wv8N6IY3eT3fZHyYEUboUh8fhcU/zYZ9FinLBgOCsJS8oektjbN7O46tA0/nHnq0e1vUYu0fm68HF/mIci9QXNOXWuogX0CRsd9mb3yan1PujQye5sMwV2oEUg5vl3MPSkmYZfN86B/8zALKcyKTTXDkpxyaWPu/XOeUf2RqDWL2cwFzgsAJ3xm3DjREC3HuqclgHTipNmMDkLaY9/WJzTcGIV3VHJbA0pEnZhWWOZgQGyCqA213gSbJBz9M+ho5RBVroENM4Cjb9z/94Oqx9OPBY4QWKxxYa9grZjKVS8PqiFAUjbaqcSnu6jsl01JW90AmmKiPIqYC5jk8ekye+F7e+Ikak/c2bADlpn2lJKntEqHZYfVbArV8HAkIQAcZNITSAw6oL3LLtGX7FxWhBotDU8+/CSwlK+EaupoTymPNhDdo0NhFmLHWhAxthJat= demo@host

Now access your remote host using the method available to you.

Once you have access to your account on the remote server, you should make sure that the ~/.ssh directory exists. This command creates the directory if necessary, or does nothing if it already exists:

mkdir -p ~/.ssh

Now you can create or modify the authorized_keys file in this directory. This command allows you to append the contents of your id_rsa.pub file to the end of the authorized_keys file and create it if necessary:

echo public-key >> ~/.ssh/authorized_keys

Replace public-key in the above command with the output of the cat ~/.ssh/id_rsa.pub command you ran on your local system. It should start with ssh-rsa AAAA…..

Finally, we make sure that the ~/.ssh directory and the authorized_keys file have the appropriate permissions:

chmod -R go= ~/.ssh

This will recursively remove all „Group“ and „Other“ permissions for the ~/.ssh/ directory.

If you use the root account to set up keys for a user account, it is also important that the ~/.ssh directory is owned by the user and not root:

chown -R username:username ~/.ssh

In this example, our user is called username. You should replace the corresponding user name in the above command.

We can now try passwordless authentication with our Ubuntu server.

Step 3 – Authenticate with your Ubuntu server using SSH keys

If you successfully complete one of the methods, you should be able to log in to the remote host without providing the remote account password.

The basic process is the same:

ssh username@remote_host

The first time you connect to this host (for example, if you used the last method above), you may see something like the following:

The authenticity of host '130.5.7.121 (130.5.7.121)' can't be established.
ECDSA key fingerprint is ea:ad:e4:A7:77:ff:13:24:e2:25:00:da:6e:d1:12:ae.
Are you sure you want to continue connecting (yes/no)? yes

This means that your local computer does not recognize the remote host. Type „yes“ and press ENTER to continue.

If you have not specified a passphrase for your private key, you will be logged in immediately. If you specified a passphrase for the private key when you created the key, you will now be prompted to enter it (note that your keystrokes will not be displayed in the terminal session for security reasons). After authentication, a new shell session should open for you with the configured account on the Ubuntu server.

If key-based authentication was successful, continue to learn how to further secure your system by disabling password authentication.

Step 4 – Disable password authentication on your server

If you were able to log in to your account using SSH without a password, you have successfully configured SSH key-based authentication for your account. However, your password-based authentication mechanism is still active, which means that your server is still vulnerable to brute force attacks.

Before you perform the steps in this section, make sure that you have either configured SSH key-based authentication for the root account on this server or, preferably, that you have configured SSH key-based authentication for a non-root account on this server with sudo privileges. This step locks password-based logins, so it’s important to make sure that you can still gain administrative access.

Once you have verified that your remote account has administrative privileges, log in to your remote server with SSH keys, either as root or with an account that has sudo privileges. Then open the configuration file of the SSH service:

sudo nano /etc/ssh/sshd_config

Look in the file for a directive called PasswordAuthentication. This line may be commented out with a # at the beginning of the line. Uncomment the line by removing the # and set the value to no. This disables the ability to log in over SSH with account passwords:

. . .
PasswordAuthentication no
. . .

Save and close the file when you are done by pressing CTRL+X, then Y to confirm saving the file, and finally ENTER to exit nano. To actually enable these changes, we need to restart the sshd service:

sudo systemctl restart ssh

As a precaution, open a new terminal window and test if the SSH service is working correctly before closing your current session:

ssh username@remote_host

Once you have verified that your SSH service is working properly, you can safely close all running server sessions.

The SSH service on your Ubuntu server now responds only to authentication with SSH keys. Password-based logins have been disabled.

Conclusion

You should now have SSH key-based authentication configured on your server so that you can log in without providing an account password.

Kategorie: Linux, Ubuntu

Einrichten von SSH-Keys unter Ubuntu 22.04

17. September 2022

SSH (Secure Shell) ist ein kryptografisch gesichertes Protokoll, das zur Verwaltung und Kommunikation mit Servern verwendet wird. Wenn Sie mit einem Ubuntu-Server arbeiten, werden Sie wahrscheinlich die meiste Zeit in einer Terminalsitzung verbringen, die über SSH mit Ihrem Server verbunden ist.

In dieser Anleitung werden wir uns auf die Einrichtung von SSH-Schlüsseln für eine Ubuntu 22.04-Installation konzentrieren. SSH-Schlüssel bieten eine sichere Möglichkeit, sich bei Ihrem Server anzumelden und werden für alle Benutzer empfohlen.

Schritt 1 – Erstellen des Schlüsselpaars

Der erste Schritt besteht darin, ein Schlüsselpaar auf dem Rechner zu erstellen:

ssh-keygen

Aktuelle Versionen von ssh-keygen erzeugen standardmäßig ein 3072-Bit-RSA-Schlüsselpaar, das für die meisten Anwendungsfälle sicher genug ist (Sie können optional die Option -b 4096 angeben, um einen größeren 4096-Bit-Schlüssel zu erzeugen).

Nach der Eingabe des Befehls sollten Sie die folgende Ausgabe sehen:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/your_username/.ssh/id_rsa):

Drücken Sie die Eingabetaste, um das Schlüsselpaar im Unterverzeichnis .ssh/ in Ihrem Home-Verzeichnis zu speichern, oder geben Sie einen alternativen Pfad an.

Wenn Sie zuvor ein SSH-Schlüsselpaar erzeugt haben, wird möglicherweise die folgende Aufforderung angezeigt:

/home/your_username/.ssh/id_rsa already exists.
Overwrite (y/n)?

Wenn Sie sich für das Überschreiben des Schlüssels auf der Festplatte entscheiden, können Sie sich nicht mehr mit dem vorherigen Schlüssel authentifizieren. Seien Sie sehr vorsichtig, wenn Sie „Ja“ wählen, da dies ein zerstörerischer Vorgang ist, der nicht rückgängig gemacht werden kann.

Sie sollten dann die folgende Aufforderung sehen:

Enter passphrase (empty for no passphrase):

Hier können Sie optional eine sichere Passphrase eingeben, was sehr empfehlenswert ist. Eine Passphrase ist ein Passwort, welches bei der Nutzung des Schlüssels abgefragt wird. Es bietet eine zusätzliche Sicherheitsebene.

Sie sollten dann eine ähnliche Ausgabe wie die folgende sehen:

Your identification has been saved in /home/your_username/.ssh/id_rsa
Your public key has been saved in /home/your_username/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:8STVn6r5nq+ABwWRlnsDaf0Ailrv4K6f5CTrEKREmyB username@hostname
The key's randomart image is:
+---[RSA 3072]----+
|+o. ++o          |
|oA . +..         |
| o   .+          |
|+    ..  .       |
|o    .o.A.  .    |
| .  o .Xo. o     |
|o.=. o .= +      |
|oO.+  .  = o     |
|*=*.o   oo=o.    |
+----[SHA256]-----+

Sie haben nun einen öffentlichen und einen privaten Schlüssel, die Sie zur Authentifizierung verwenden können. Der nächste Schritt besteht darin, den öffentlichen Schlüssel auf Ihrem Server abzulegen, damit Sie sich mit der SSH-Schlüssel-Authentifizierung anmelden können.

Schritt 2 – Kopieren des öffentlichen Schlüssels auf Ihren Ubuntu-Server

Der schnellste Weg, Ihren öffentlichen Schlüssel auf einen Ubuntu-Host zu kopieren, ist die Verwendung des Dienstprogramms ssh-copy-id. Aufgrund seiner Einfachheit ist diese Methode sehr empfehlenswert, sofern verfügbar natürlich. Wenn Ihnen ssh-copy-id auf Ihrem Client-Rechner nicht zur Verfügung steht, können Sie eine der beiden alternativen Methoden verwenden, die in diesem Abschnitt beschrieben werden (Kopieren über passwortbasiertes SSH oder manuelles Kopieren des Schlüssels).

Kopieren des öffentlichen Schlüssels mit ssh-copy-id

Das Tool ssh-copy-id ist in vielen Betriebssystemen standardmäßig enthalten, so dass es auf Ihrem lokalen System verfügbar sein dürfte. Damit diese Methode funktioniert, müssen Sie bereits über einen passwortbasierten SSH-Zugang zu Ihrem Server verfügen.

Um das Tool zu verwenden, geben Sie den entfernten Host an, zu dem Sie eine Verbindung herstellen möchten, sowie das Benutzerkonto, zu dem Sie passwortbasierten SSH-Zugang haben. Dies ist das Konto, auf das Ihr öffentlicher SSH-Schlüssel kopiert wird.

Dazu verwenden wir folgenden Befehl:

ssh-copy-id username@remote_host

Folgende Meldung wird ausgegeben:

The authenticity of host '130.5.7.121 (130.5.7.121)' can't be established.
ECDSA key fingerprint is ea:ad:e4:A7:77:ff:13:24:e2:25:00:da:6e:d1:12:ae.
Are you sure you want to continue connecting (yes/no)? yes

Das bedeutet, dass Ihr lokaler Computer den entfernten Host nicht erkennt. Dies ist der Fall, wenn Sie zum ersten Mal eine Verbindung zu einem neuen Host herstellen. Geben Sie „yes“ ein und drücken Sie ENTER, um fortzufahren.

Als Nächstes wird das Dienstprogramm Ihr lokales Konto nach dem Schlüssel id_rsa.pub durchsuchen, den wir zuvor erstellt haben. Wenn es den Schlüssel findet, werden Sie aufgefordert, das Passwort für das Konto des entfernten Benutzers einzugeben:

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
username@130.5.7.121's password:

Geben Sie das Passwort ein (Ihre Eingabe wird aus Sicherheitsgründen nicht angezeigt) und drücken Sie ENTER. Das Dienstprogramm verbindet sich mit dem Konto auf dem entfernten Host unter Verwendung des von Ihnen angegebenen Passworts. Es kopiert dann den Inhalt Ihres ~/.ssh/id_rsa.pub-Schlüssels in die Datei authorized_keys im Home-Verzeichnis ~/.ssh des entfernten Kontos.

Sie sollten die folgende Ausgabe sehen:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'username@130.5.7.121'"
and check to make sure that only the key(s) you wanted were added.

Jetzt ist Ihr Schlüssel id_rsa.pub auf das entfernte Konto hochgeladen worden. Sie können nun mit Schritt 3 fortfahren.

Kopieren des öffentlichen Schlüssels mit SSH

Wenn der Befehl ssh-copy-id nicht verfügbar ist, aber einen passwortbasierten SSH-Zugang zu einem Konto auf Ihrem Server haben, können Sie Ihre Schlüssel mit einer herkömmlichen SSH-Methode hochladen.

Dazu lesen wir mit dem Befehl cat den Inhalt des öffentlichen SSH-Schlüssels auf unserem lokalen Computer und leiten ihn über eine SSH-Verbindung an den entfernten Server weiter.

Auf der anderen Seite können wir sicherstellen, dass das Verzeichnis ~/.ssh unter dem von uns verwendeten Konto existiert und die richtigen Berechtigungen hat.

Dann können wir den Inhalt, den wir über die Pipeline übertragen haben, in eine Datei namens authorized_keys innerhalb dieses Verzeichnisses ausgeben. Wir werden das Umleitungssymbol >> verwenden, um den Inhalt anzuhängen, anstatt ihn zu überschreiben. Auf diese Weise können wir Schlüssel hinzufügen, ohne zuvor hinzugefügte Schlüssel zu zerstören.

Der vollständige Befehl sieht wie folgt aus:

cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"

Es folgt folgende Ausgabe:

The authenticity of host '130.5.7.121 (130.5.7.121)' can't be established.
ECDSA key fingerprint is ea:ad:e4:A7:77:ff:13:24:e2:25:00:da:6e:d1:12:ae.
Are you sure you want to continue connecting (yes/no)? yes

Das bedeutet, dass Ihr lokaler Computer den entfernten Host nicht erkennt. Dies ist der Fall, wenn Sie zum ersten Mal eine Verbindung zu einem neuen Host herstellen. Geben Sie „yes“ ein und drücken Sie ENTER, um fortzufahren.

Anschließend sollten Sie aufgefordert werden, das Kennwort für das entfernte Benutzerkonto einzugeben:

username@130.5.7.121's password:

Nachdem Sie Ihr Passwort eingegeben haben, wird der Inhalt Ihres Schlüssels id_rsa.pub an das Ende der Datei authorized_keys des Benutzerkontos der Gegenstelle kopiert. Wenn dies erfolgreich war, fahren Sie mit Schritt 3 fort.

Manuelles Kopieren des öffentlichen Schlüssels

Wenn Sie keinen passwortbasierten SSH-Zugang zu Ihrem Server haben, müssen Sie den obigen Prozess manuell durchführen.

Wir fügen den Inhalt Ihrer Datei id_rsa.pub manuell an die Datei ~/.ssh/authorized_keys auf Ihrem entfernten Rechner an.

Um den Inhalt Ihres id_rsa.pub-Schlüssels anzuzeigen, geben Sie Folgendes auf Ihrem lokalen Computer ein:

cat ~/.ssh/id_rsa.pub

Sie sehen den Inhalt des Schlüssels, der etwa so aussehen sollte:

ssh-rsa AAAAB4NzaC2yc2EAAAADAQABAAABgQC0YsVakZH8GBkHFBYmg8eeJX5LrFH7y8PHmLJDMGYvdnKSoASzo5zKKgzTVveEe82wv8N6IY3eT3fZHyYEUboUh8fhcU/zYZ9FinLBgOCsJS8oektjbN7O46tA0/nHnq0e1vUYu0fm68HF/mIci9QXNOXWuogX0CRsd9mb3yan1PujQye5sMwV2oEUg5vl3MPSkmYZfN86B/8zALKcyKTTXDkpxyaWPu/XOeUf2RqDWL2cwFzgsAJ3xm3DjREC3HuqclgHTipNmMDkLaY9/WJzTcGIV3VHJbA0pEnZhWWOZgQGyCqA213gSbJBz9M+ho5RBVroENM4Cjb9z/94Oqx9OPBY4QWKxxYa9grZjKVS8PqiFAUjbaqcSnu6jsl01JW90AmmKiPIqYC5jk8ekye+F7e+Ikak/c2bADlpn2lJKntEqHZYfVbArV8HAkIQAcZNITSAw6oL3LLtGX7FxWhBotDU8+/CSwlK+EaupoTymPNhDdo0NhFmLHWhAxthJat= demo@host

Nun greifen Sie mit der Ihnen zur Verfügung stehenden Methode auf Ihren entfernten Host zu.

Sobald Sie Zugang zu Ihrem Konto auf dem entfernten Server haben, sollten Sie sicherstellen, dass das Verzeichnis ~/.ssh existiert. Dieser Befehl erstellt das Verzeichnis, falls erforderlich, oder tut nichts, wenn es bereits existiert:

mkdir -p ~/.ssh

Nun können Sie die Datei authorized_keys in diesem Verzeichnis erstellen oder ändern. Mit diesem Befehl können Sie den Inhalt Ihrer Datei id_rsa.pub an das Ende der Datei authorized_keys anfügen und sie gegebenenfalls erstellen:

echo public-key >> ~/.ssh/authorized_keys

Ersetzen Sie public-key im obigen Befehl durch die Ausgabe des Befehls cat ~/.ssh/id_rsa.pub, den Sie auf Ihrem lokalen System ausgeführt haben. Er sollte mit ssh-rsa AAAA…. beginnen.

Zum Schluss stellen wir sicher, dass das Verzeichnis ~/.ssh und die Datei authorized_keys mit den entsprechenden Berechtigungen versehen sind:

chmod -R go= ~/.ssh

Dadurch werden rekursiv alle „Gruppen“- und „Andere“-Berechtigungen für das Verzeichnis ~/.ssh/ entfernt.

Wenn Sie das root-Konto verwenden, um Schlüssel für ein Benutzerkonto einzurichten, ist es auch wichtig, dass das ~/.ssh-Verzeichnis dem Benutzer und nicht root gehört:

chown -R username:username ~/.ssh

In diesem Beispiel heißt unser Benutzer username. Sie sollten den entsprechenden Benutzernamen im obigen Befehl ersetzen.

Wir können nun die passwortlose Authentifizierung mit unserem Ubuntu-Server versuchen.

Schritt 3 – Authentifizierung bei Ihrem Ubuntu-Server mit SSH-Schlüsseln

Wenn Sie eine der Methoden erfolgreich abgeschlossen haben, sollten Sie in der Lage sein, sich beim entfernten Host anzumelden, ohne das Passwort des entfernten Kontos anzugeben.

Der grundlegende Vorgang ist derselbe:

ssh username@remote_host

Wenn Sie zum ersten Mal eine Verbindung zu diesem Host herstellen (wenn Sie z.B. die letzte Methode oben verwendet haben), sehen Sie möglicherweise etwas wie das Folgende:

The authenticity of host '130.5.7.121 (130.5.7.121)' can't be established.
ECDSA key fingerprint is ea:ad:e4:A7:77:ff:13:24:e2:25:00:da:6e:d1:12:ae.
Are you sure you want to continue connecting (yes/no)? yes

Das bedeutet, dass Ihr lokaler Computer den entfernten Host nicht erkennt. Geben Sie „yes“ ein und drücken Sie ENTER, um fortzufahren.

Wenn Sie keine Passphrase für Ihren privaten Schlüssel angegeben haben, werden Sie sofort angemeldet. Wenn Sie bei der Erstellung des Schlüssels eine Passphrase für den privaten Schlüssel angegeben haben, werden Sie jetzt aufgefordert, diese einzugeben (beachten Sie, dass Ihre Tastenanschläge aus Sicherheitsgründen nicht in der Terminalsitzung angezeigt werden). Nach der Authentifizierung sollte sich für Sie eine neue Shell-Sitzung mit dem konfigurierten Konto auf dem Ubuntu-Server öffnen.

Wenn die schlüsselbasierte Authentifizierung erfolgreich war, fahren Sie fort, um zu erfahren, wie Sie Ihr System weiter absichern können, indem Sie die Passwortauthentifizierung deaktivieren.

Schritt 4 – Deaktivieren der Kennwortauthentifizierung auf Ihrem Server

Wenn Sie sich mit SSH ohne Kennwort bei Ihrem Konto anmelden konnten, haben Sie die SSH-schlüsselbasierte Authentifizierung für Ihr Konto erfolgreich konfiguriert. Ihr passwortbasierter Authentifizierungsmechanismus ist jedoch immer noch aktiv, was bedeutet, dass Ihr Server weiterhin für Brute-Force-Angriffe anfällig ist.

Bevor Sie die Schritte in diesem Abschnitt ausführen, vergewissern Sie sich, dass Sie entweder die SSH-Schlüssel-basierte Authentifizierung für das Root-Konto auf diesem Server konfiguriert haben oder vorzugsweise, dass Sie die SSH-Schlüssel-basierte Authentifizierung für ein Nicht-Root-Konto auf diesem Server mit sudo-Rechten konfiguriert haben. Mit diesem Schritt werden passwortbasierte Anmeldungen gesperrt, so dass Sie unbedingt sicherstellen müssen, dass Sie weiterhin administrativen Zugriff erlangen können.

Sobald Sie sich vergewissert haben, dass Ihr entferntes Konto über administrative Rechte verfügt, melden Sie sich mit SSH-Schlüsseln bei Ihrem entfernten Server an, entweder als root oder mit einem Konto mit sudo-Rechten. Öffnen Sie dann die Konfigurationsdatei des SSH-Dienstes:

sudo nano /etc/ssh/sshd_config

Suchen Sie in der Datei nach einer Direktive namens PasswordAuthentication. Diese Zeile kann mit einem # am Anfang der Zeile auskommentiert sein. Heben Sie die Auskommentierung der Zeile auf, indem Sie das # entfernen, und setzen Sie den Wert auf no. Dadurch wird die Möglichkeit, sich über SSH mit Kontopasswörtern anzumelden, deaktiviert:

. . .
PasswordAuthentication no
. . .

Speichern und schließen Sie die Datei, wenn Sie fertig sind, indem Sie STRG+X drücken, dann Y, um das Speichern der Datei zu bestätigen, und schließlich ENTER, um nano zu beenden. Um diese Änderungen tatsächlich zu aktivieren, müssen wir den sshd-Dienst neu starten:

sudo systemctl restart ssh

Öffnen Sie vorsichtshalber ein neues Terminalfenster und testen Sie, ob der SSH-Dienst korrekt funktioniert, bevor Sie Ihre aktuelle Sitzung schließen:

ssh username@remote_host

Sobald Sie sich vergewissert haben, dass Ihr SSH-Dienst ordnungsgemäß funktioniert, können Sie alle laufenden Serversitzungen sicher schließen.

Der SSH-Dienst auf Ihrem Ubuntu-Server reagiert jetzt nur noch auf die Authentifizierung mit SSH-Schlüsseln. Passwortbasierte Anmeldungen wurden deaktiviert.

Fazit

Sie sollten nun eine SSH-Schlüssel-basierte Authentifizierung auf Ihrem Server konfiguriert haben, so dass Sie sich ohne Angabe eines Kontopassworts anmelden können.

Kategorie: Linux, Ubuntu, Uncategorized

How To Disable Root Login on Ubuntu 22.04

10. September 2022

On every Linux system, the user „root“ is created as the first user by default. The root user has the highest privileges and has full access to all commands and files with unlimited read, write and execute permissions. It is important to note that improper or inappropriate use of this user account can have a significant impact on your server.

In this tutorial, you will learn how to disable root login on an Ubuntu system to prevent unauthorized root access via SSH and improve the security of your Linux system.

Disable root login

sudo nano /etc/ssh/sshd_config
...
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
...

Change the value of the PermitRootLogin setting from yes to no:

...
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
...

Save and close the file.

Use the following command to restart the SSH service and apply the settings:

sudo systemctl restart sshd

This command restarts the sshd service with systemctl.

In this step, we changed the configuration file to deny root logins, restarted the sshd service to apply the configuration. Next, test whether root login is disabled or not by trying to log in to your server as root.

Test root login

After you disable root login, try to log in as root in a new terminal session using SSH. Use the following commands depending on your preferred login mechanism.

If you use the password-based login:

ssh root@server_ip

The attempt to SSH as root will fail with an error message like this:

root@server_ip: Permission denied (publickey).

Kategorie: Linux, Ubuntu

So deaktivieren Sie den Root-Login unter Ubuntu 22.04

10. September 2022

Auf jedem Linux-System wird standardmäßig der Benutzer „root“ als erster Benutzer angelegt. Der Root-Benutzer besitzt die höchsten Rechte und hat vollen Zugriff auf alle Befehle und Dateien mit uneingeschränkten Lese-, Schreib- und Ausführungsberechtigungen. Es ist wichtig zu beachten, dass unsachgemäßer oder unangemessener Gebrauch dieses Benutzerkontos erhebliche Auswirkungen auf Ihren Server haben kann.

In diesem Tutorial erfahren Sie, wie Sie den Root-Login auf einem Ubuntu-System deaktivieren können, um unbefugten Root-Zugriff über SSH zu verhindern und die Sicherheit Ihres Linux-Systems zu verbessern.

Root-Login deaktivieren

sudo nano /etc/ssh/sshd_config
...
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
...

Ändern Sie den Wert der Einstellung PermitRootLogin von yes auf no:

...
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
...

Speichern und schließen Sie die Datei.

Verwenden Sie den folgenden Befehl, um den SSH-Dienst neu zu starten und die Einstellungen zu übernehmen:

sudo systemctl restart sshd

Mit diesem Befehl wird der sshd-Dienst mit systemctl neu gestartet.

In diesem Schritt haben wir die Konfigurationsdatei geändert, um Root-Logins zu verweigern, den Dienst sshd neu gestartet, um die Konfiguration zu übernehmen. Als Nächstes testen Sie, ob der Root-Login deaktiviert ist oder nicht, indem Sie versuchen, sich als Root auf Ihrem Server anzumelden.

Root-Login testen

Nachdem Sie die Root-Anmeldung deaktiviert haben, versuchen Sie, sich in einer neuen Terminalsitzung mit SSH als Root anzumelden. Verwenden Sie die folgenden Befehle je nach Ihrem bevorzugten Anmeldemechanismus.

Wenn Sie die passwortbasierte Anmeldung verwenden:

ssh root@server_ip

The attempt to SSH as root will fail with an error message like this:

root@server_ip: Permission denied (publickey).

Kategorie: Linux, Ubuntu

  • « Go to Previous Page
  • Seite 1
  • Seite 2
  • Seite 3
  • Seite 4
  • Seite 5
  • Seite 6
  • Interim pages omitted …
  • Seite 16
  • Go to Next Page »

Haupt-Sidebar

  • How to remove dashicons in WordPress frontend?
  • How do I create a website (homepage) with ChatGPT?
  • Can I create a website (homepage) with ChatGPT?
  • iOS restrictions re: bringing up the keyboard on programmatic focus
  • iOS restrictions re: bringing up the keyboard on programmatic focus
  • Remove user listing from WP-JSON
  • Benutzerauflistung aus WP-JSON entfernen
  • What does „Video is not the main content of the page“ mean?
  • Was hat es mit „Das Video ist nicht der Hauptinhalt der Seite“ auf sich?
  • Remove WordPress logo from toolbar
  • Efficient onboarding simplified: LearnSuite – the cloud application for digital onboarding
  • Wir stellen vor: LearnSuite – Die Cloudanwendung für digitales Onboarding
  • Howto: How do I create a website (homepage) with ChatGPT?
  • Howto: Wie erstelle ich mit ChatGPT eine Website (Homepage)?
  • Can I create a website (homepage) with ChatGPT?
  • Kann ich mit ChatGPT eine Website (Homepage) erstellen?
  • Set noindex nofollow via .htaccess HTTP header
  • Über .htaccess X-Robots-Tag noindex nofollow setzen
  • How to remove WordPress Dashicons in frontend?
  • Wie lassen sich Dashicons im WordPress-Frontend entfernen?
  • DSGVO (3)
  • GDPR (3)
  • Genesis Framework (10)
  • Genesis-Framework (9)
  • Google Search Console (4)
  • Google Search Console (4)
  • Linux (3)
  • Linux (3)
  • mobile (3)
  • Mobile (3)
  • Network (1)
  • Netzwerk (1)
  • SEO (5)
  • SEO (5)
  • Trends (3)
  • Trends (4)
  • Uncategorized (3)
  • Web development (1)
  • Web hosting (1)
  • Webentwicklung (1)
  • Webhosting (1)
  • WooCommerce (9)
  • WooCommerce (9)
  • WordPress (24)
  • WordPress (23)

Footer

Logo




© 2026 CITROWEB
  • Datenschutz
  • Impressum