Créer clés (ed25519 ici) :
ssh-keygen -t ed25519
Déployer clé publique :
ssh-copy-id -i /home/user_local/.ssh/id_ed25519.pub user_remote@host_remote
SSH Copy revient à :
cat ~/.ssh/id_rsa.pub | ssh user_remote@host_remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
nano /etc/ssh/ssh_config
HashKnownHosts yes
Host *
ConnectTimeout 60
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
ServerAliveInterval 1800
ControlMaster auto
ControlPersist yes
ControlPath ~/.ssh/socket-%r@%h:%p
Permissions :
chmod 700 ~/.ssh/ #le dossier en lui-même
find ~/.ssh/ -type f -exec chmod 600 {} \; #les fichiers qu'il contient
nano ~/.ssh/config
Ajouter vos hôtes :
Host serveur1
ssh_option1 <valeur1>
ssh_option2 <valeur2>
ssh_option3 <valeur3>
Host serveur2
ssh_option1 <valeur1>
ssh_option2 <valeur2>
Host *
ssh_option1 <valeur1>
Par exemple :
Host www
HostName 192.168.1.201
Port 42022
User liandri
Host db
HostName 192.168.1.202
Port 42022
User liandri
Host *
User liandri
Protocol 2
Compression yes
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 60
ServerAliveCountMax 30
LogLevel INFO
...
Permissions du fichier de configuration :
chmod 0700 ~/.ssh/config
Il suffit enfin de se connecter à l'aide de l'alias :
ssh www