search
top

SSH, les séquences d’échappement

Cela peut par exemple vous servir pour gérer ou retrouver vos tunnel.

Extrait du man :

 ESCAPE CHARACTERS
     When a pseudo-terminal has been requested, ssh supports a number of func-
     tions through the use of an escape character.

     A single tilde character can be sent as ~~ or by following the tilde by a
     character other than those described below.  The escape character must
     always follow a newline to be interpreted as special.  The escape charac-
     ter can be changed in configuration files using the EscapeChar configura-
     tion directive or on the command line by the -e option.

     The supported escapes (assuming the default `~') are:

     ~.      Disconnect.

     ~^Z     Background ssh.

     ~#      List forwarded connections.

     ~&      Background ssh at logout when waiting for forwarded connection /
             X11 sessions to terminate.

     ~?      Display a list of escape characters.

     ~B      Send a BREAK to the remote system (only useful for SSH protocol
             version 2 and if the peer supports it).

     ~C      Open command line.  Currently this allows the addition of port
             forwardings using the -L, -R and -D options (see above).  It also
             allows the cancellation of existing port-forwardings with
             -KL[bind_address:]port for local, -KR[bind_address:]port for re-
             mote and -KD[bind_address:]port for dynamic port-forwardings.
             !command allows the user to execute a local command if the
             PermitLocalCommand option is enabled in ssh_config(5).  Basic
             help is available, using the -h option.

     ~R      Request rekeying of the connection (only useful for SSH protocol
             version 2 and if the peer supports it).

Monter un partition distante via SSH

Installer sshfs :

apt-get install sshfs

Mettez vous dans le groupe « fuse »

Pour monter une partition distante :

sshfs host: pointdemontage

Pour démonter :

fusermount -upointdemontage

Documentation sshfs complete : http://fuse.sourceforge.net/sshfs.html

Mettre à l’heure une machine distant en ssh

Pour mettre a l’heure une machine distante avec la date et heure du système local, utiliser ssh comme ci dessous.

Les options de date permette d’envoyer la date et l’heure au bon format au système distant.

ssh 1.2.3.4 date `date +’%m%d%H%M%y’`

Convertir ca clef Putty en clef OpenSSH

  1. Lancez PuttyGen, la clef privée généré par putty est dans un format proprietaire.
  2. Chargez votre clef privée dans putty gen
  3. Dans le menu Conversions, cliquez sur « Export OpenSSH key »

Voila, vous avez votre clef privée au format OpenSSH Pour une clef RSA, placer votre clef privée dans le fichier ~/.ssh/id_rsa

Votre clef public dans le fichier ~/.ssh/id_rsa.pub et/ou dans ~/.ssh/authorized_keys

Pour les clef DSA, cela se passe exactement de la meme maniere sauf que se sera ~/.ssh/id_dsa et ~/.ssh/id_dsa.pub

Connexion SSH par clés

Pré requis :

putty-0.60-installer

Créer ces clés

  • Pour créer la clef publique et privée, utilisez puttygen.exe
    • Cochez SSH2 RSA
    • Cliquez sur generate
    • Bougez la souris dans la fenêtre
    • Key comment : Votre login ou vitre nom
    • Key passphrase : Entrez un mot de passe à ne pas oublier
    • Sauvegardez la clef publique et privée

Installer la clé publique sur le serveur

Copier votre clef pour la coller à la suite du fichier /.ssh/authorized_keys.

Une clef doit tenir impérativement sur une ligne sinon plus rien ne marche.
Pour créer simplement ce fichier tapez dans un shell ;

echo 'votreclefpublique' >> authorized_keys

Configurer putty pour qu’il utilise votre clé

  • Lancer pageant si je n’est déjà fait
  • Chargez votre clef privée dans pageant (clique doit sur son icône dans la barre des taches, Add key)
  • Dans la configuration de putty :
    • Connexion autologin : root
    • SSH cochez la version 2 du protocol
    • SSH/Auth : Cochez Allow agent fowarding
  • Sauvegardez la session.

Connexion

  • Clic droit sur Pageant dans la barre des taches ;
  • Puis dans « saved session » sélectionner la session que vous désirer ouvrir.

« Articles précédents

top