User Tools

Site Tools


servermanagement:ssh

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

servermanagement:ssh [2022/12/23 10:13] – created dimitrijservermanagement:ssh [2022/12/23 11:51] (current) dimitrij
Line 1: Line 1:
-====== SSH Konfiguration ====== +====== SSH ======
-In diesem Eintrag soll es um die Grundlegende SSH Konfiguration gehen. Ausgegangen wird von der initialen Einrichtung eines Server wie [[Server buchen|hier]] beschrieben. Daher werden einige Abschnitte bei anderen Grundvorraussetzungen optional und können übersprungen werden.+
  
-===== Initial Connection ===== +To connect to a Linux server using SSH (Secure Shell)you will need to have an SSH client installed on your computer. If you don't have an SSH client installed, you can install one such as OpenSSH or PuTTY.
-Wenn auf dem Server SSH eingerichtet istso werden die Stadard Einstellungen genutztEine Verbindung kann daher mit dem folgenden Befehlt erfolgen:+
  
-''ssh root@[IP-ADDRESS-OF-SERVER]''+Once you have an SSH client installed, you can use the following steps to connect to a Linux server:
  
-**Es empfiehlt sich immer eine zusätzliche Verbindung aufzubauen, welche als Backup genutzt werden kann, wenn man sich bei Fehlern aus dem System aussperrt**+  - Open your SSH client. 
 +  - Enter the hostname or IP address of the Linux server you want to connect to in the "Hostname" or "Server" field. 
 +  - Enter the port number for the SSH service on the server (usually 22). 
 +  - Enter your username for the server in the "Username" field. 
 +  - Click the "Connect" or "Open" button to initiate the connection.
  
-Hat man nun zwei Terminals geöffnetso kann man eines der Beiden dazu Nutzen die Konfiguration vorzunehmen.+If the server requires a passwordyou will be prompted to enter it. If the server uses key-based authentication, you may need to provide the path to your private key file.
  
-== Creating user on a Linux machine and securing the connection with a private key ==+Once you have successfully connected to the server, you should see command prompt where you can enter commands to interact with the server.
  
-1. Log in to your Linux machine as a user with sudo privileges.+===== Terminal =====
  
-2. Run the `adduser` command to create a new user. Replace `USERNAME` with the desired username:+When you are on a Mac oder Linux machine, you can use the terminal and connect to your server using the following command:
  
-''sudo adduser USERNAME''+''ssh username@server_hostname_or_IP''
  
-3. Follow the prompts to set the user's password and other information.+Here is an overview of some of the most commonly used options for the ssh command, along with their syntax:
  
-4. To allow the new user to log in using a private key, you will need to generate a public/private key pair. Run the following command to generate a new SSH key pair:+  * '' -l--login USERNAME'': This option allows you to specify the username to use when logging in to the server. The syntax for using this option is''ssh -l USERNAME server_hostname_or_IP''
  
-''ssh-keygen -t rsa''+  * '' -p, --port PORT_NUMBER'': This option allows you to specify the port number to use for the SSH connection. The default port number for SSH is 22, but it can be changed on the server. The syntax for using this option is: ''ssh -p PORT_NUMBER server_hostname_or_IP''
  
-5. Press `Enter` to accept the default location and file name for the key pairYou will be prompted to enter a passphrase for the key. It is highly recommended to use a strong, unique passphrase to protect your key.+  * '' -i, --identity-file PATH'': This option allows you to specify the path to a private key file to use for key-based authenticationThe syntax for using this option is: ''ssh -i /path/to/private_key server_hostname_or_IP''
  
-6. Once the key pair is generated, you can view the public key by running the following command:+  * '' -o--option NAME=VALUE'': This option allows you to specify options in the format ''name=value''. You can use this option to specify a variety of options, such as the number of retries to attempt when connecting to the server, the amount of time to wait between retries, or the preferred encryption algorithms to use. The syntax for using this option is''ssh -o "option_name=option_value" server_hostname_or_IP''
  
-''cat ~/.ssh/id_rsa.pub'' +  * '' -v, --verbose'': This option increases the verbosity of the ssh command, causing it to display more detailed information about the connection processThis can be useful for troubleshooting connection issuesThe syntax for using this option is: ''ssh -v server_hostname_or_IP''
- +
-7. Copy the output of the `cat` command, which is your public key. +
- +
-8. Switch to the new user's account by running the following command: +
- +
-''mkdir ~/.ssh'' +
- +
-10Open a new file in the `.ssh` directory called `authorized_keys` using a text editor, such as `nano`: +
- +
-''nano ~/.ssh/authorized_keys'' +
- +
-11. Paste the public key that you copied earlier into the `authorized_keys` file. +
- +
-12. Save and close the file. +
- +
-13. Set the correct permissions on the `.ssh` directory and `authorized_keys` file to protect them from unauthorized access: +
- +
-''chmod 700 ~/.ssh'' +
- +
-''chmod 600 ~/.ssh/authorized_keys'' +
- +
-14. Exit the new user's account by running the `exit` command. +
- +
-15. You should now be able to log in to the new user's account using the private key. To do so, run the following command from your local machine, replacing `USERNAME` with the username of the new user and `HOSTNAME` with the hostname or IP address of the Linux machine: +
- +
-''ssh -i ~/.ssh/id_rsa USERNAME@HOSTNAME'' +
- +
- +
-You will be prompted to enter the passphrase for the private key. Once you enter the correct passphrase, you should be logged in to the new user's account on the Linux machine. +
- +
-===== sshd_config ===== +
- +
-Leider ist die Konfiguration je nach Betriebssystem anders untergebracht. Für gewöhnlich findet man diese jedoch unter ''/etc/ssh/sshd_config''. Für die Bearbeitung wird [[vim|Vim]] empfohlen. Auch ist durch den Ort, an welchem die Datei abgelegt ist notwendig, dass man die Bearbeitung mit sudo Rechten durchführt, da sonst das Speichern nicht erlaubt wird. +
- +
-Das Konfigurationsfile hat viele Optionen und daher erhebt die Nachfolgende Liste keinen Anspruch auf vollständigkeit. Die Zeilen sind zudem meist auskommentiert, was durch ein ''#'' zu beginn der Zeile angedeutet wird. Dieses muss für das aktivieren der Option entsprechend entfernt werden. +
- +
-  * ''Port'' gibt den Port an, auf welchem SSH lauscht. Es wird empfohlen diesen zu ändern, da Angreifer zu meiste den dafault Por 22 angreifen +
-  * ''PermitRootLogin'' gibt an, ob ein Login als root User möglich ist. Hier empfiehlt sich, die option auf no zu setzen, da der root User die einfachste Angriffsfläche bietet+
servermanagement/ssh.txt · Last modified: 2022/12/23 11:51 by dimitrij

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki