Aller au contenu

SSH#

Erreurs Fréquentes#

  • Bad owner or permissions on /root/.ssh/config: chmod 644 ~/.ssh/config

Installation#

Bash
apt install openssh-client

Générer une pair de clé RSA public/privé#

Bash
ssh-keygen -t rsa -b 4096

Générer un certificat#

Bash
1
2
3
4
5
6
7
8
9
NAME="o7test"
# Generate a 2048 RSA private Key
openssl genrsa 2048 > $NAME.pem

# convert to PKCS8 format
openssl pkcs8 -topk8 -nocrypt -inform PEM -in $NAME.pem -out $NAME-in-PKCS8.pem

# Generate the certificate
openssl req -new -x509 -nodes -sha256 -days 365 -key $NAME.pem -outform PEM -out $NAME-certificate.pem

Conventions#

  • Default pour cle prive: ~/.ssh/id_rsa
  • Default pour cle publique: ~/.ssh/id_rsa.pub

Autres Commandes#

Bash
1
2
3
4
5
6
7
8
# Ajouter la cle public d'un serveur au fichier hote local
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts

# Convertir PEM to P7B
openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer

# Générer une clé aléatoire de 32 charactères
openssl rand -base64 32

Test Key#

Bash
ssh -T git@gitlab.com

SSH Serveur#

Installation#

Bash
apt install openssh-server

Ajoutde Certificat#

Bash
1
2
3
# Add your github Public Key
# https://manpages.ubuntu.com/manpages/bionic/man1/ssh-import-id.1.html
ssh-import-id gh:<github username>

Site de Référence#

  • Pour la conversion de certificats: https://www.sslshopper.com/ssl-converter.html