Logo Khaganat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:connexion_serveur_admin [2017/01/02 18:48] – created Domperssen:connexion_serveur_admin [2021/12/03 18:19] (current) – external edit 127.0.0.1
Line 4: Line 4:
 <WRAP center round important 60%> <WRAP center round important 60%>
 The manipulation here concerns a console connection from a Linux machine. The manipulation here concerns a console connection from a Linux machine.
-</ WRAP>+</WRAP>
  
 The advantage of connecting to a server using a public key is that you can forget the basic passwords of the servers, there is only one to remember: **yours**. This is very useful if you have several servers to administer, or if they have passwords to extend and impossible to remember. The advantage of connecting to a server using a public key is that you can forget the basic passwords of the servers, there is only one to remember: **yours**. This is very useful if you have several servers to administer, or if they have passwords to extend and impossible to remember.
Line 10: Line 10:
 ===== Generating the key ===== ===== Generating the key =====
 **Open a console and generate a pair of keys by typing:** **Open a console and generate a pair of keys by typing:**
-   <code>ssh-keygen -t rsa</code>+   ssh-keygen -t rsa
        
 You should have the following text displayed: You should have the following text displayed:
Line 20: Line 20:
 Your public key has been saved in /home/user/.ssh/id_rsa.pub.</code> Your public key has been saved in /home/user/.ssh/id_rsa.pub.</code>
  
-A public/private key is generated, using the RSA algorithm specifically for ssh connections. Do not enter anything for the file to save the key(leave in ''/home/user/.ssh/id_rsa'', so tap on "entry"). For the "passphrase", find an effective password. It's often simpler if this is the same as your public password.+A public/private key is generated, using the RSA algorithm specifically for ssh connections. Do not enter anything for the file(for saving of the keyleave ''/home/user/.ssh/id_rsa'', so just tap for "entry"). For the "passphrase", find an effective password. It's often simpler if this is the same as your public password.
  
  
 **Copy the key to the remote server account** **Copy the key to the remote server account**
-   <code>ssh-copy-id -i ~ / .ssh / id_rsa.pub yyy@xxxxx.org</code>+   ssh-copy-id -i ~ / .ssh / id_rsa.pub yyy@xxxxx.org
  
 Replace ''yyy@xxxxx.org'' with the name of your server and it's user, for example ''root@myserver.org''. Enter the server password (NOT your key passphrase, the server must know that it is you!). Replace ''yyy@xxxxx.org'' with the name of your server and it's user, for example ''root@myserver.org''. Enter the server password (NOT your key passphrase, the server must know that it is you!).
  
 And now, it's all good! You can connect to the server via ssh with your key: And now, it's all good! You can connect to the server via ssh with your key:
-   <code>ssh yyy@xxxxx.org</code>+   ssh yyy@xxxxx.org
 or or
-   <code>ssh root@myserver.org</code>+   ssh root@myserver.org
  
 On the server, go to the .ssh folder of /home/user and On the server, go to the .ssh folder of /home/user and
 +<code>More authorized_keys</code>
 A line must end with your username and the name of your machine, these are the public keys allowed to connect. A line must end with your username and the name of your machine, these are the public keys allowed to connect.
  
Line 40: Line 41:
 It is possible to automatically indicate to SSH to use this or that key according to the site to which one connects. It is possible to automatically indicate to SSH to use this or that key according to the site to which one connects.
  
-Suppose we have generated two RSA keys as described above. Simply specify a different name for the question "/home/user/.ssh/id_rsa": "/home/user/.ssh/cle1and '/home/user/.ssh/cle2' '. It was therefore decided to use the keys as follows:+Suppose we have generated two RSA keys as described above. Simply specify a different name for the question "/home/user/.ssh/id_rsa:" ''/home/user/.ssh/cle1'' and ''/home/user/.ssh/cle2''. It is therefore decided to use the keys as follows:
  
-  * cle1  pour aller sur le serveur +  * Cle1 goes to server 
-  * cle2 pour aller sur le serveur 2+  * Cle2 goes to server 2
  
-Il faut alors créer un fichier ''config'' dans son répertoire ''.ssh'' dans son /home. Il contiendra pour chaque serveur un identifiantson nom (ou adresse IP directe), le fichier rsa à utiliser et l'identifiant qui y est lié :+It is necessary to create the file ''config'' in it's directory ''.ssh'' in the /home directoryIt contain(for each server) an identifierits name(or direct IP address), the file rsa to use and the identifier that is linked to it:
  
-<code txt config> +<code
-host serveur1 +<txt config> 
- HostName serveur1.fr+host server1 
 + HostName server1.en
  IdentityFile ~/.ssh/cle1  IdentityFile ~/.ssh/cle1
  User totor  User totor
      
-host serveur2+host server2
  HostName 202.127.12.13  HostName 202.127.12.13
  IdentityFile ~/.ssh/cle2  IdentityFile ~/.ssh/cle2
Line 59: Line 61:
 </code> </code>
  
-Ensuite quand on se connectera avec SSH, le système saura que pour aller sur serveur1.fr, il faut qu'il utilise la clef ~/.ssh/cle1 et l'identifiant totor. Il ne restera qu'à entrer la passphrase qui y est liéeIl n'y a plus besoin de donner la clef nécessaire ou l'identifiantjuste éventuellement le port si il n'est pas standard.+Then when you connect with SSH, the system will know to go to "server1.fr"it must use the key ~/.ssh/cle1 and the identifier "totor"It will remain __only__ to enter the passphrase that is related to itThere is no longer the need to give the necessary key or identifierjust possibly the port number if it's not an standard one.
  
-Par exemple +For example 
-Accès au serveur 1 qui un port standard :+Access to server1 that has a standard port:
 <code bash> <code bash>
 ~$ ssh serveur1.fr ~$ ssh serveur1.fr
 </code> </code>
  
-Accès au serveur qui a son port SSH ouvert au numéro 66666 :+Access to server which has its SSH port open at 66666:
 <code bash> <code bash>
 ~$ ssh -p 66666 202.127.12.13 ~$ ssh -p 66666 202.127.12.13
 </code> </code>
-===== Se connecter sans mot de passe (méthode non sécurisée) ===== +===== Log in without password(insecure method) ===== 
-<WRAP center round important 60%> +<WRAP centeralign round important 80%> 
-Se connecter sans mot de passe ouvre potentiellement une faille de sécuritéÀ réserver à des cas très particuliers !+Logging in without a password potentially opens up a security vulnerabilityTo be reserved for very special cases!
 </WRAP> </WRAP>
-Un de ces cas est la possibilité pour un serveur de se connecter à un serveur B, pour effectuer une sauvegarde des données par exempleLe serveur doit lui-même être bien protégé.+One of these cases is the possibility for a server(A) to connect to a server(B) for data backup for exampleServer(A) itself must then be __well protected__.
  
-Il suffit de créer une clé sur le serveur A, comme indiqué plus haut (''ssh-keygen -t rsa''mais de ne pas rentrer de mot de passeCette clé pourra donc être utilisée pour se connecter sans mot de passe.+It is enough to create a key on the server(A)as indicated above in: (''ssh-keygen -t rsa''but not to enter a passwordThis key can therefore be used to connect without a password.
  
-Ensuite on ajoute cette clé sur le serveur B (''ssh-copy-id -i ~/.ssh/id_rsa.pub yyy@xxxxx.org''). +Then we add this key to server(B(''ssh-copy-id -i ~/.ssh/id_rsa.pub yyy@xxxxx.org'').
  
-Comme les fichiers id_rsa et id_rsa.pub peuvent facilement être copiés d'un ordinateur à l'autreon peut sécuriser un peu en faisant en sorte que le serveur n'accepte la clé du serveur que si cette clé est utilisé depuis l'adresse IP du serveur A. +As the "id_rsa" and "id_rsa.pub" files can easily be copied from one computer to anotherone can secure a little more by making sure that the server(B) only accepts the key of the server(A) if this key is used from the IP address of server(A).
  
-Il faut alors ajouter "from=IP1,IP2" dans le fichier ''authorized_keys'', au début de la clé en question.+It is necessary to add "from=IP1, IP2" in the file "authorized_keys"(at the beginning of the key in question).
  
-Exemple +Example
-  from="192.02.300.01" ssh-rsa XXXYYYZZZ(clé) user@server+   from="192.02.300.01" ssh-rsa XXXYYYZZZ(key) user@server
  
-===== Se connecter sans retaper trop souvent son mot de passe (méthode sécurisée) ===== +===== Log in without too often retyping your password(secure method) ===== 
-Il suffit d'utiliser un "agent sshqui va se souvenir de votre cléEn théorievotre mot de passe ne devrait être demandé qu'une fois par session, la première fois que vous déverrouillez la clé.+Just use an "ssh agent" that will remember your keyIn theoryyour password should only be requested once per session + the first time you unlock the key.
  
-  eval "$(ssh-agent -s)"+  Evaluate "$(ssh-agent -s)"
   ssh-add ~/.ssh/id_rsa   ssh-add ~/.ssh/id_rsa
  
  
-===== Pour aller plus loin ===== +===== To go further ===== 
-  * [[http://doc.fedora-fr.org/wiki/SSH_:_Authentification_par_cl%C3%A9|Une explication plus complète sur les clés ssh, en français.]]+  * [[http://doc.fedora-fr.org/wiki/SSH_:_Authentification_par_cl%C3%A9|A more complete explanation of the ssh keysin French.]]
  
-{{tag>Serveur Administration Sécurité}}+{{tag>Serveur Sysadmin Sécurité}}
CC Attribution-Share Alike 4.0 International Driven by DokuWiki
en/connexion_serveur_admin.1483382927.txt.gz · Last modified: (external edit)

Licences Mentions légales Accueil du site Contact Inclusion