Metafor

ULiege - Aerospace & Mechanical Engineering

User Tools

Site Tools


devel:misc:ssh

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:misc:ssh [2016/05/13 16:44] – [SSH keys] bomandevel:misc:ssh [2017/07/10 18:12] (current) – [SSH keys] boemer
Line 3: Line 3:
 A guide about how to configure and use SSH in Ubuntu.  The following questions will be answered in this guide: A guide about how to configure and use SSH in Ubuntu.  The following questions will be answered in this guide:
  
- * How to log into a remote machine?+  * How to log into a remote machine?
  
- * How to configure the login properly with an SSH key and a config file?+  * How to configure the login properly with an SSH key and a config file?
  
- * How to transfer files from one machine to another?+  * How to transfer files from one machine to another?
  
  
 ===== Log into a remote machine ===== ===== Log into a remote machine =====
  
-Different remote machines are usually used during the software development, like //clifton//, //blueberry// or the cluster //fabulous// The most direct way to log into one of these machines is to open a terminal and to enter the following command:+Different remote machines are usually used during the software development, like //spring//, //blueberry// or the cluster //fabulous// The most direct way to log into one of these machines is to open a terminal and to enter the following command:
  
   ssh username@machine   ssh username@machine
Line 18: Line 18:
 For instance, For instance,
  
-  ssh boemer@clifton.ltas.ulg.ac.be+  ssh boemer@blueberry.ltas.ulg.ac.be
  
 The terminal then asks for the password and the connection is established.  Once logged in, it is possible to execute all kinds of commands on the remote machine.  Finally, to leave the remote machine, the command ''exit'' has to be executed.   The terminal then asks for the password and the connection is established.  Once logged in, it is possible to execute all kinds of commands on the remote machine.  Finally, to leave the remote machine, the command ''exit'' has to be executed.  
Line 24: Line 24:
 Always having to type the full ''username@machine'' specification as well as the password can become tiring in the long run.  For this reason, it is explained in the following section how to log into a remote machine by a command as simple as the following one, without having to enter a password: Always having to type the full ''username@machine'' specification as well as the password can become tiring in the long run.  For this reason, it is explained in the following section how to log into a remote machine by a command as simple as the following one, without having to enter a password:
  
-  ssh clifton+  ssh blueberry
  
  
Line 36: Line 36:
 SSH keys are similar to passwords.  They can be created by the command ''ssh-keygen'' During the creation of the key files, the user is asked to enter a keyphrase.  This keyphrase is an additional password, which can be used with the key files.  If you do, however, not want to add any further security, you can simply press Enter.  The ''ssh-keygen'' command then creates two files in the ''.ssh'' directory (in ''$HOME''): a private identification key called ''id_rsa'' and a public verification key ''id_rsa.pub''.   SSH keys are similar to passwords.  They can be created by the command ''ssh-keygen'' During the creation of the key files, the user is asked to enter a keyphrase.  This keyphrase is an additional password, which can be used with the key files.  If you do, however, not want to add any further security, you can simply press Enter.  The ''ssh-keygen'' command then creates two files in the ''.ssh'' directory (in ''$HOME''): a private identification key called ''id_rsa'' and a public verification key ''id_rsa.pub''.  
  
-The public key has to be transfered to the remote machine by the command ''ssh-copy-id username@machine'', e.g. ''ssh-copy-id boemer@clifton.ltas.ulg.ac.be'' This command adds the alpha-numeric key in ''id_rsa.pub'' to the file ''.ssh/authorized_keys'' on the remote machine.+The public key has to be transfered to the remote machine by the command ''ssh-copy-id username@machine'', e.g. ''ssh-copy-id boemer@blueberry.ltas.ulg.ac.be'' This command adds the alpha-numeric key in ''id_rsa.pub'' to the file ''.ssh/authorized_keys'' on the remote machine.
  
 When you try to connect for the next time to the remote machine, no password will be asked since the ssh command compares your private key in ''.ssh/id_rsa'' with the public key in ''.ssh/authorized_keys'' on the remote machine.  If the comparison is successful, the connection is established.  In reality, a more complex operation than a simple comparison is performed.  See [[https://en.wikipedia.org/wiki/RSA_%28cryptosystem%29|RSA]]. When you try to connect for the next time to the remote machine, no password will be asked since the ssh command compares your private key in ''.ssh/id_rsa'' with the public key in ''.ssh/authorized_keys'' on the remote machine.  If the comparison is successful, the connection is established.  In reality, a more complex operation than a simple comparison is performed.  See [[https://en.wikipedia.org/wiki/RSA_%28cryptosystem%29|RSA]].
Line 43: Line 43:
 <note tip> You might want to connect from one remote machine immediately to another remote machine without entering the password, e.g. <note tip> You might want to connect from one remote machine immediately to another remote machine without entering the password, e.g.
  
-  ssh boemer@clifton.ltas.ulg.ac.be+  ssh boemer@blueberry.ltas.ulg.ac.be
   ssh boemer@fabulous.ltas.ulg.ac.be   ssh boemer@fabulous.ltas.ulg.ac.be
      
-The easiest way to do so is to copy your private key ''id_rsa'' to the first remote machine, provided that the public key ''id_rsa.pub'' has already been trasfered to the second remote machine by the ''ssh-copy-id'' command.  The private key is transfered to the first remote machine by the following command:+The easiest way to do so is to copy your private key ''id_rsa'' to the first remote machine, provided that the public key ''id_rsa.pub'' has already been transfered to the second remote machine by the ''ssh-copy-id'' command.  The private key is transfered to the first remote machine by the following command:
  
-  scp .ssh/id_rsa boemer@clifton.ltas.ulg.ac.be:.ssh/+  scp .ssh/id_rsa boemer@blueberry.ltas.ulg.ac.be:.ssh/
  
 </note> </note>
Line 60: Line 60:
  
  
-<note warning> Previously, it was suggested to copy your private key ''id-rsa'' on all machines.  Notice that whoever has this key can access your machines.  It is as if he had your password.  So pay attention to not leave this file on machines accessible by people, who you do not know. </note>+<note warning> Previously, it was suggested to copy your private key ''id_rsa'' on all machines.  Notice that whoever has this key can access your machines.  It is as if he had your password.  So pay attention to not leave this file on machines accessible by people, who you do not know. </note>
  
  
Line 67: Line 67:
 To log into a remote machine by typing To log into a remote machine by typing
  
-  ssh clifton +  ssh blueberry
      
 instead of instead of
  
-  ssh boemer@clifton.ltas.ulg.ac.be+  ssh boemer@blueberry.ltas.ulg.ac.be
      
 a configuration file named ''config'' has to be created in the ''.ssh'' folder.  In the previous example, this file should contain the following content: a configuration file named ''config'' has to be created in the ''.ssh'' folder.  In the previous example, this file should contain the following content:
  
-  Host clifton +  Host blueberry 
-      HostName clifton.ltas.ulg.ac.be+      HostName blueberry.ltas.ulg.ac.be
       User boemer       User boemer
       IdentityFile ~/.ssh/id_rsa       IdentityFile ~/.ssh/id_rsa
Line 85: Line 85:
 ===== File transfer ===== ===== File transfer =====
  
-Besides using FileZilla, files can also be directly transfered by SSH, or more precisely, by SCP, i.e. Secure Copy.  For instance, the ''config'' file of the previous section can be copied into the ''.ssh'' folder of another machine, say clifton, by the following command:+Besides using FileZilla, files can also be directly transfered by SSH, or more precisely, by SCP, i.e. Secure Copy.  For instance, the ''config'' file of the previous section can be copied into the ''.ssh'' folder of another machine, say blueberry, by the following command:
  
-  scp .ssh/config boemer@clifton.ltas.ulg.ac.be:.ssh/+  scp .ssh/config boemer@blueberry.ltas.ulg.ac.be:.ssh/
  
 Or, in short, Or, in short,
  
-  scp .ssh/config clifton:.ssh/+  scp .ssh/config blueberry:.ssh/
  
  
devel/misc/ssh.1463150662.txt.gz · Last modified: 2016/05/13 16:44 by boman

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki