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[<em>bind_address</em>:]<em>port</em> for local, -KR[<em>bind_address</em>:]<em>port</em> for re-
             mote and -KD[<em>bind_address</em>:]<em>port</em> for dynamic port-forwardings.
             !<em>command</em> allows the user to execute a local command if the
             PermitLocalCommand option is enabled in <a href="http://man.openbsd.org/">ssh_config(5)</a>.  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).
rtfm  ssh 

Activer/Désactiver l'écran de veille Gnome

La commande suivante retournera “True” ou “False”

gconftool-2 --get /apps/gnome-screensaver/idle_activation_enabled
  • True, la detection de l’inactivité est activée, l’écran de veille se déclenchera.
  • False, la détection de l’inactivité est désactivé, il n’y a donc pas de mise en veille.

Pour modifier cela :

gconftool-2 --type bool --set /apps/gnome-screensaver/idle_activation_enabled "false/true"

Pour ne pas verrouiller l’écran lorsque l’écran de veille se déclenche :

gconftool-2 --type boolean -s /apps/gnome-power-manager/lock_on_blank_screen false
gconftool-2 --type boolean -s /apps/gnome-power-manager/lock_use_screensaver_settings false

Remplacer false par true pour faire le contraire 😉

[Lire]

tar - Removing leading '/' from member names

Lorsque vous faite vos tar en utilisant des chemins relatif et non absolut, tar vous renverra surement dans STDOUT le message suivant :

tar: Removing leading ‘/’ from member names

Pour éviter cela (cela peut être gênant dans des scripts) ajouter l’option -P

tar 

Dropbox sous linux en ligne de commande

Dropbox propose un script en Python (sous licence libre GPL v3) permettant d’administrer sa Dropbox à partir de la ligne de commande cotre serveur. Pour récupérer et installer la dernière version du script, il faut saisir les commandes suivantes:

cd ~/
wget -O dropbox.py http://www.dropbox.com/download?dl=packages/dropbox.py
chmod a+rx dropbox.py
sudo mv dropbox.py /usr/local/bin/

On lance le script sans paramètre pour voir la liste des fonctions disponibles:

/usr/local/bin/dropbox.py

Dropbox command-line interface commands: status       get current status of the dropboxd help         provide help puburl       get public url of a file in your dropbox filestatus   get current sync status of one or more files ls           list directory contents with current sync status```

[Lire]

Configuration cliente SSH avancée

Voir [cet article]({{ relref . “1119-multiplexer-plusieurs-connections-ssh-en-une.md” }}) concernant le “multiplexage” des connections.

Cet exemple de configuration ne vérifie pas le hash et ne le stock pas

Host 192.168.1.1
  HashKnownHosts          no
  StrictHostKeyChecking   no
  ControlMaster           auto
  ControlPath             ~/.ssh/sockets/%r-%h-%p
  Compression             yes
  KeepAlive               yes
  CheckHostIP             no

Cet exemple de configuration s’applique a tous les autre host, stock le hash

Host *
  HashKnownHosts          yes
  StrictHostKeyChecking   ask
  ControlMaster           auto
  StrictHostKeyChecking   yes
  ControlPath             ~/.ssh/sockets/%r-%h-%p
  Compression             yes
  KeepAlive               yes
  CheckHostIP             yes

Dans les deux exemple, une socket de connexion sera créé dans le dossier ~/.ssh/sockets

[Lire]

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'\`

Sinon, il y a ntpd :)

date  ssh