rss
twitter
  • Showcase
  • Carrières
  • Support
  • GitLab
  • Espace client
  • Contact

Connexion SSH avec clé

2

Sur la machine source :

$ ssh-keygen -t dsa -b 2048 -f ~/rsync-key
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase): [press enter here]
Enter same passphrase again: [press enter here]
Your identification has been saved in /home/user/rsync-key.
Your public key has been saved in /home/user/rsync-key.pub.
The key fingerprint is:
xxxxxxxxxxxxxxxxxxxx user@localhost

Copier la clé sur la machine cible :

scp ~/rsync-key.pub user@remotehost:~

Mettre la clé dans la liste des utilisateurs autorisés sur la machine cible :

mkdir ~/.ssh
chmod 700 ~/.ssh
mv ~/rsync-key.pub ~/.ssh/
cd ~/.ssh/
touch authorized_keys2
chmod 600 authorized_keys2
cat rsync-key.pub >> authorized_keys2

Restreindre l’accès avec cette clé à l’IP de la machine source :

cible$ / # cd ~  
cible$ ~ # cd .ssh/
cible$ .ssh # nano authorized_keys2

Et ajouter au début de la ligne :

from= »IP_MACHINE_SOURCE » ssh-dss AAAAB3NzaC1kc3MAAACBALaAOSPPc7Fb0pZ7v(…)

À partir de la machine source, on peut maintenant se connecter sans taper de password :

ssh -i ~/rsync-key user@remote

Exemple basique pour faire un backup à partir de la machine cible :

rsync -avz -e "ssh -i /Users/germain/rsync-key" /dossier_source/ user@remotehost:/home/backups/ > logs_rsync.txt

 

DATE 14 Mar 2009
by : Germain
Author / Auteur

Social Share / Partager

    2 Comments
    1. Glob30 18 décembre 2012 at 15 h 06 min Répondre

      Merci pour cette astuce et ce tutorial très clair.
      Cela faisait plusieurs jours que je galérais et maintenant, tout fonctionne à merveille !
      Super

    2. admin_i 18 décembre 2012 at 15 h 08 min Répondre

      Merci pour la précision, cher haha.

    Leave a Reply / Répondre Annuler la réponse

    *
    *

    More in Uncategorized

    • Pense-bête LESS CSS / SASS
    • Alcatel-Lucent IP Touch 4008/18 / 4019 : rechercher dans le répertoire
    • Snippets Kohana pour Sublime Text 2
    • Récupérer infos et vignettes d’une vidéo YouTube
    • Certificats SSL chez GeoTrust / RapidSSL : problèmes d’autorité intermédiaire de certification

    Search the blog

    Blog categories

    • Workflow (1)
    • Front-end : HTML, CSS (13)
    • Front-end : javascript, jQuery (33)
    • Back-end : PHP, CMS (42)
    • Back-end : SQL, MySQL (20)
    • Sysadmin : Linux, Apache, GIT (75)
    • Designers : tools, advice (2)
    • Desktop : OS X (37)
    • Desktop : Microsoft (12)
    • Uncategorized (8)

    ITALIC™ Resources

    • Paramètres de connexion au serveur mail
    • Graphistes : séduire un développeur web
    • Dév front : nos bonnes pratiques
    • Mailing : nos (bonnes ?) pratiques
    • Environnement de travail Mac

    Recent posts

    • Autoriser le chargement de contenus mixtes non-https dans Chrome (Mac)
    • Afficher les logs MySQL
    • Recevoir un mail lors de la connexion root à un serveur
    • Changer l’interclassement de plusieurs tables MySQL à la fois (ou presque
    • Maildev : tester l’envoi de mails durant ses développements
    © 2008-2017 ITALIC™ • 8 bis rue Abel • 75012 PARIS • Tel +33 (0)1 48 44 46 35 • RCS PARIS 508 228 772 • Powered by WordPress & GoodLayers
    Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site web.
    Cookie settingsACCEPTER
    Manage consent

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Toujours activé
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    Enregistrer & appliquer