Catégories

Recommander

Recherche

Vendredi 25 août 2006
SSH permet de se connecter à serveur de façon sécurisée en cryptant les données transitant entre le client et le serveur.

Cependant, un serveur ssh "mal configuré" peut être un véritable trou de sécurité. Un individu mal intentionné peut forcer le mot de passe et se connecter sur votre serveur.

Le fichier sur lequel nous allons travailler se nomme sshd_config et se situe dans /etc/ssh/.

Voici à quoi ressemble le fichier :

# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 600
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

# Change to yes to enable tunnelled clear text passwords
PasswordAuthentication no


# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

Subsystem     sftp    /usr/lib/sftp-server

UsePAM yes


Nous allons modifier maintenant celui-ci pour mieux sécuriser notre accès.

Port d'écoute :

On change le port 22 par un nombre (celui que l'on veut) ex : 5943.
Si vous avez plusieurs cartes réseau sur votre machine, vous pouvez utilisez à la place la ligne ListenAdress, ex : 192.168.1.1:5943 et l'autre carte 192.168.3.1:564.

Les utilisateurs :

Par défaut root peut se logguer en ssh. Ceci représente un vrai danger, car avec une brute-force attack on peut casser le mot de passe. Donc PermitRootLogin no.

On va autoriser un seul utilisateur. On fait un useradd Raoul93 (avec un mot de passe genre "P@ss0rd")et on autorise celui-ci et lui seul à se connecter en ssh en ajoutant la ligne suivante à la fin du fichier : AllowUsers Raoul93.

Se connecter au serveur :

Depuis votre machine cliente, lancez :

$ ssh Raoul93@serveur -p 5943


C'est fini !
Par Olivier82 - Publié dans : Debian
Ecrire un commentaire - Voir les 2 commentaires - Recommander
Retour à l'accueil
Créer un blog sur over-blog.com - Contact - C.G.U. - Rémunération en droits d'auteur - Signaler un abus