SSH/fr

SSH (Secure SHell) est un programme de terminal chiffré qui remplace telnet, l'outil classique des systèmes d'exploitation du type Unix.

In addition to remote terminal access provided by the main binary, the SSH suite of programs has grown to include other tools such as  (Secure Copy Program) and  (Secure File Transfer Protocol).

À l'origine, SSH n'était pas libre. Cependant, de nos jours, la mise en œuvre la plus populaire de SSH, qui constitue un standard de fait, est l'OpenSSH de OpenBSD. Cette version est pré-installée sur Gentoo.

Vérifier l'installation
Most deployments of Gentoo Linux will already have OpenSSH installed on the system. This can be checked by running the command. If it is installed a usage statement should be printed:

If no usage statement is printed is either corrupted or not installed. It is also possible that a user is simply rebuilding OpenSSH to include a new USE configuration. Whatever the case, proceed on to view possible USE settings.

Emerge
Une fois les paramètres USE changés, n'oubliez pas d'installer (ou de recompiler) OpenSSH.

Créer des clés
Pour vous fournir un shell sécurisé, des clés de chiffrage sont utilisées pour le chiffrage, le déchiffrage et les fonctionnalités de hâchage offertes par SSH.

On the first start of the SSH service, system keys will be generated. Keys can be (re)generated using the command.

Pour générer les clés utilisées par la version 1 du protocole SSH (qui n'est normalement plus activé et a été rendu obsolète au profit de la version 2 du protocole), utilisez :

Pour générer les clés les clés pour la version 2 du protocole SSH (algorythmes DSA et RSA):

Configuration du serveur
Le serveur SSH est ordinairement configuré dans le fichier, bien qu'il soit aussi possible de compléter la configuration dans le fichier d'OpenRC, y compris le changement de l'emplacement du fichier de configuration. Pour une information détaillée sur la manière de configurer le serveur, reportez-vous à la page de manuel de sshd_config.

Les utilisateurs cherchant une configuration centrée sur la sécurité devraient se référer guide de Sven.

Configuration du client
The client and related programs (,, etc.) can be configured using the following files:



Pour une information plus complète reportez-vous à la page de manuel :

Passwordless authentication
Pratique pour la gestion du serveur git.

Client
Sur votre client, exécutez :

Serveur
Make sure an account for the user exists on the server, and then place the clients' file into the server's  file in the user's home directory.

Single machine testing
La procédure mentionnée ci-dessus peut être testée localement :

Intrusion prevention
SSH is a commonly attacked service. Tools such as sshguard and fail2ban monitor logs and black list remote users who have repeatedly attempted, yet failed to login. Utilize them as needed to secure a frequently attacked system.

OpenRC
Add the OpenSSH daemon to the default runlevel:

Start the sshd daemon with:

The OpenSSH server can be controlled like any other OpenRC-managed service:

Systemd
To have the OpenSSH daemon start when the system starts:

To start the OpenSSH daemon now:

To check if the service has started:

Troubleshooting
There are 3 different levels of debug modes that can help troubleshooting issues. With the  option SSH prints debugging messages about its progress. This is helpful in debugging connection, authentication, and configuration problems. Multiple  options increase the verbosity. Maximum verbosity is three levels deep.

Death of long-lived connections
Many internet access devices perform Network Address Translation (NAT), a process that enables devices on a private network such as that typically found in a home or business place to access foreign networks, such as the internet, despite only having a single IP address on that network. Unfortunately, not all NAT devices are created equal, and some of them incorrectly close long-lived, occasional-use TCP connections such as those used by SSH. This is generally observable as a sudden inability to interact with the remote server, even though the client program has not exited.

In order to resolve the issue, OpenSSH clients and servers can be configured to send a 'keep alive', or invisible message aimed at maintaining and confirming the live status of the link:


 * To enable keep alive for all clients connecting to your local server, set  (or some other value, in seconds) within the  file.
 * To enable keep alive for all servers connected to by your local client, set  (or some other value, in seconds) within the  file.

X11 forwarding, not forwarding, or tunneling
Problem: After having made the necessary changes to the configuration files for permitting X11 forwarding, it is discovered X applications are executing on the server and are not being forwarded to the client.

Solution: What is likely occurring during SSH login into the remote server or host, the DISPLAY variable is either being unset or is being set after the SSH session sets it.

Test for this scenario perform the following after logging in remotely:

The output should be something similar to  or   using server side   setting. If the usual  is not displayed, check to make sure the DISPLAY variable within  is not being unset or re-initializing. If it is, remove or comment out any custom initialization of the DISPLAY variable to prevent the code in from executing during a SSH login:

Be sure to substitute  in the command above with the proper username.

A trick that works to complete this task would be to define an alias within the users' file.

External resources

 * Securing OpenSSH - Gentoo developer documentation.