Ma configuration pour me connecter avec ssh, sans avoir à introduire de mot de passe.

Par R. Suinot: rsuinux@gmx.fr

Contenu


Introduction

J'ai cherché comment avoir un shell sur le serveur de la maison, à partir du portable. Le type de connexion passe par ssh, bien sur (surtout depuis que j'ai l'adsl), mais à chaque fois, j'avais le mot de passe du compte distant à fournir. Au bout d'un momment, ça lasse. J'ai donc commencé par chercher comment faire, puis j'ai eu pas mal de problème. En fin de compte, j'ai réussi à executer ce que je voulais! J'ai décidé de placer ici ma configuration, ayant eu beaucoup de mal à trouver les bonnes informations d'un coup, sur le net.
J'ai trouvé de l'aide sur l'excellent site lea-linux, ainsi que grâce à la documentation en ligne de Denis Bodor: "http://okki666.free.fr/docmaster/articles/linux123.html

Ce petit document N'EST PAS un guide d'installation et/ou configuration de ssh! C'est juste ma façon de le configurer!


Configuration

Je pars du principe que vous utilisez l'installation sur une debian, bien sur! Les essais se font sur deux compte situé sur mon portable. C'est pourquoi vous verez souvent la reference à localhost comme machine distante.
La version utilisée est la suivante:

$ dpkg -l ssh
Souhait=inconnU/Installé/suppRimé/Purgé/H=à garder
| État=Non/Installé/fichier-Config/dépaqUeté/échec-conFig/H=semi-installé
|/ Err?=(aucune)/H=à garder/besoin Réinstallation/X=les deux (État,Err: majuscule=mauvais)
||/ Nom                             Version                         Description
+++-===============================-===============================-==============================================================================
ii  ssh                             3.6.1p2-10                      Secure rlogin/rsh/rcp replacement (OpenSSH)

Avant tout, reportez vous sur les 'man' des fichiers de configuration de ssh, c'est à dire:
  • /etc/ssh/ssh_config
  • /etc/ssh/sshd_config
  • Les utilisateurs doivent avoir un répertoire ~/.ssh.
    Sur mon portable, j'ai deux utilisateurs:
    drwxr-xr-x    2 dev      dev          4096 2003-11-24 05:12 .ssh
    drwxr-xr-x    2 admin    admin        4096 2003-11-24 05:11 .ssh
    
    Faite bien attention aux autorisations des fichiers/répertoires. Cela peut entrainer quelques petit problèmes...

    Avant d'essayer, regardons mes fichiers de config:
    /etc/ssh/ssh_config:
    
    #       $OpenBSD: ssh_config,v 1.16 2002/07/03 14:21:05 markus Exp $
     
    # This is the ssh client system-wide configuration file.  See
    # ssh_config(5) for more information.  This file provides defaults for
    # users, and the values can be changed in per-user configuration files
    # or on the command line.
    
    # Configuration data is parsed as follows:
    #  1. command line options
    #  2. user-specific file
    #  3. system-wide file
    # Any configuration value is only changed the first time it is set.
    # Thus, host-specific definitions should be at the beginning of the
    # configuration file, and defaults at the end.
    
    # Site-wide defaults for various options
    
    Port 22
    Protocol 2
    Host *
    ForwardAgent yes
    ForwardX11 yes
    # RhostsAuthentication no
    # RhostsRSAAuthentication no
    # RSAAuthentication yes
    PubkeyAuthentication yes
    PasswordAuthentication yes
    # BatchMode yes
    # HostbasedAuthentication no
    # CheckHostIP no
    # StrictHostKeyChecking ask
    # IdentityFile ~/.ssh/identity
    IdentityFile ~/.ssh/id_rsa
    IdentityFile ~/.ssh/id_dsa
    # EnableSSHKeysign yes
    # Cipher 3des
    # Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
    # EscapeChar ~
    

    /etc/ssh/sshd_config:
    
    # Package generated configuration file
    # See the sshd(8) manpage for defails
    
    # 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
    
    # ...but breaks Pam auth via kbdint, so we have to turn it off
    # Use PAM authentication via keyboard-interactive so PAM modules can
    # properly interface with the user (off due to PrivSep)
    PAMAuthenticationViaKbdInt no
    # Lifetime and size of ephemeral version 1 server key
    KeyRegenerationInterval 3600
    ServerKeyBits 768
     
    # Logging
    SyslogFacility AUTH
    LogLevel INFO
    
    # Authentication:
    LoginGraceTime 600
    PermitRootLogin no
    # StrictModes yes
     
    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile%h/.ssh/authorized_keys
    
    # rhosts authentication should not be used
    RhostsAuthentication no
    # 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
    
    # Uncomment to disable s/key passwords
    #ChallengeResponseAuthentication no
    
    # To disable tunneled clear text passwords, change to no here!
    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 yes
    X11DisplayOffset 10
    PrintMotd no
    #PrintLastLog no
    KeepAlive yes
    # UseLogin no
    
    #MaxStartups 10:30:60
    #Banner /etc/issue.net
    #ReverseMappingCheck yes
     
    Subsystem       sftp    /usr/lib/sftp-server
    


    essai


    Conclusion




    S'il vous arrivait de vous servir de cette doc, envoyez moi un petit mot, merci!