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

Next revision
Previous revision
devel:misc:ssh [2016/04/26 16:58] – created boemerdevel: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 config file?+  * How to configure the login properly with an SSH key and 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.  One can then 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.  
  
 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 34: Line 34:
 ==== SSH keys ==== ==== SSH keys ====
  
-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'' 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@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.
  
-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 string 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.+
  
  
 <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>
  
  
-<note important> It might happen that your file permissions in the ''.ssh'' folder are not sufficiently restrictive.  To change these permissions execute the following command in the home directory+<note important> It might happen that your file permissions in the ''.ssh'' folder are not sufficiently restrictive.  To change these permissions execute the following command in the home directory:
  
   chmod -R 700 .ssh   chmod -R 700 .ssh
      
-This command sets the permission recursively for all files in the ''.ssh'' directory to read/write/execute only allowed by the user. </note>+This command sets the permission recursively for all files in the ''.ssh'' directory to "read/write/execute only allowed by the user". </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 poeplewhich 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 peoplewho you do not know. </note>
  
  
 ==== Config file ==== ==== Config file ====
  
 +To log into a remote machine by typing
  
 +  ssh blueberry
 +  
 +instead of
 +
 +  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:
 +
 +  Host blueberry
 +      HostName blueberry.ltas.ulg.ac.be
 +      User boemer
 +      IdentityFile ~/.ssh/id_rsa
 +
 +Additional defintions can simply be added to this file.  If these abbreviations should also work on other machines, the ''config'' file has to be copied into the ''.ssh'' folder of these machines, 
  
  
 ===== File transfer ===== ===== File transfer =====
  
-Besides using FileZilla, files can also be directly transfered by SSH, or more precisely, SCP, i.e. Secure Copy.+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@blueberry.ltas.ulg.ac.be:.ssh/ 
 + 
 +Or, in short, 
 + 
 +  scp .ssh/config blueberry:.ssh/ 
  
  
  
  
devel/misc/ssh.1461682706.txt.gz · Last modified: 2016/04/26 16:58 by boemer

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki