===== Réseau =====
=== rsync par SSH ===
rsync -P -rsh HOST:/chemin/de/source/ chemin/de/destination/
''HOST'' étant définis dans ''~/.ssh/config''
=== Utiliser Mosh et un serveur de rebond pour des connexion instables ===
Dans le cas d'une connexion instable, [[man>mosh]] est un excellent outil ([[https://github.com/mobile-shell/mosh|github]])
Mon objectif est de pouvoir ouvrir rapidement une connexion vers mon serveur de rebond, et y retrouver tous mes hôtes habituels.
#!/bin/bash
#
# usefull to connect to an host using a mosh jump server when using poor internet on the client side.
#
# The Jump server on witch mosh is installed as defined in ~/.ssh/config
JUMP_SERVER="MY_JUMP_SERVER"
# de UDP port to use on the server, leave empty for default.
MOSH_PORT="12345"
echo "Updating SSH bookmarks from ~/.ssh/config"
grep -Eo "Host [A-Za-z0-9_-]+" ~/.ssh/config | cut -c 6- | sed -e 's/^/ssh /' > ~/.bookmarks-ssh
echo "uploading ~/.ssh/config to jump server"
scp ~/.ssh/config $JUMP_SERVER:~/.ssh/config
if [ ! "$MOSH_PORT" ];then
echo "No port defined"
mosh $JUMP_SERVER
else
echo "Port $MOSH_PORT defined"
mosh -p $MOSH_PORT $JUMP_SERVER
fi
Afin d'accélérer la connexion une fois le serveur de rebond atteint, j'utilise la même méthode que dans [[fr:tools:linux:misc-tools#bookmarks|ce script]] pour taper à la vitesse de l'éclair le nom d'hôte souhaité à partir de ''.bookmarks-ssh''.