sshkey
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sshkey [2011/04/05 16:04] – cangiani | sshkey [2022/08/05 13:20] (current) – admin | ||
---|---|---|---|
Line 2: | Line 2: | ||
You can connect to the servers using the SSH protocol without the need to insert the password every time you connect. The trick is to generate a encripted key that can be used by the systems to recognize yourself and allow your access to local resources. | You can connect to the servers using the SSH protocol without the need to insert the password every time you connect. The trick is to generate a encripted key that can be used by the systems to recognize yourself and allow your access to local resources. | ||
This behaviour can be used when you are using the Servers from the Epfl Network, but also when you connect to the server from outside the Epfl. | This behaviour can be used when you are using the Servers from the Epfl Network, but also when you connect to the server from outside the Epfl. | ||
+ | ===== Setup ===== | ||
- | ===== Ssh without password from local workstation ===== | ||
==== Generate the public/ | ==== Generate the public/ | ||
Line 12: | Line 12: | ||
* Execute this command | * Execute this command | ||
- | $ ssh-keygen -t dsa | + | $ ssh-keygen -t ed25519 |
- | * When the system ask a name for the file **id_dsa** just press enter | + | * When the system ask a name for the file **id_ed25519**, just press enter |
- | * The system will ask your for a password. This is the password that is used to encrypt your private key file (id_dsa) so that, even if the file gets stolen, it cannot be used. Try to generate a [[strongpass|strong password]]. | + | * The system will ask your for a password. This is the password that is used to encrypt your private key file (id_ed25519) so, even if the file gets stolen, it cannot be used. Try to generate a strong password. |
- | * Now you have to append the content of your public key file '' | + | * Now you have to append the content of your public key file '' |
- | $ cat ~/ | + | $ ssh-copy-id <USERNAME>@lth.epfl.ch |
* In our cluster, all the machines have access to the same home directory. Therefore you can use standard local copy: | * In our cluster, all the machines have access to the same home directory. Therefore you can use standard local copy: | ||
- | $ cat ~/.ssh/id_dsa.pub >> ~/ | + | $ cat ~/.ssh/id_ed25519.pub >> ~/ |
- | From now, every time you connet | + | From now, every time you connect |
+ | |||
+ | In fact, since your private key is encrypted, you need to type the password to decrypt it each time you want to use it. Seems like we have just replaced the "enter remote machine password" | ||
==== Setup ssh-agent ==== | ==== Setup ssh-agent ==== | ||
- | In fact, since your private key is encrypted, | + | Ssh-agent is a program that keeps in memory |
- | Ssh-agent is a program that keeps in memory your decrypted private | + | === On desktop sessions === |
+ | All modern desktop environment (os X, Gnome, KDE), do take care automatically the ssh key decryption business | ||
- | Let's set it up. | + | === On console === |
+ | If you are not on a full desktop environment (e.g. if you ssh to a machine from where you want to connect to [several] another machines), then you have to setup the ssh-agent business by hand. | ||
+ | The two (actually three) steps are | ||
+ | * launch '' | ||
+ | $ eval `ssh-agent -s` | ||
- | ==== Apple Os X & Linux ==== | + | * ask '' |
- | | + | |
- | * Execute the command | + | |
- | | + | * before logging out you have to remember to kill the ssh-agent: |
- | + | ||
- | | + | |
- | * Do the same for the **id_dsa.pub** file | + | |
- | * cd in your .ssh directory with | + | |
- | + | ||
- | $ cd ~/.ssh | + | |
- | + | ||
- | * Execute this command | + | |
- | $ cat id_dsa.pub | + | $ ssh-agent -k |
- | * Open another window and from this connect | + | Since this is quite cumbersome, I suggest |
- | * cd in .ssh directory with | + | |
- | | + | < |
+ | # only for interactive shell | ||
+ | if [ "$PS1" ]; then | ||
+ | # run ssh agent if not already running | ||
+ | SSHAGENT=/ | ||
+ | if [ -z " | ||
+ | eval `$SSHAGENT -s` | ||
+ | alias ssh=' | ||
+ | trap " | ||
+ | fi | ||
+ | fi | ||
+ | </ | ||
- | * Execute | + | This will start '' |
- | + | ||
- | $ cat >> authorized_keys | + | |
- | * Now copy & paste with the mouse the key you have in the first window (something that start with sh-dss AAAAB3NzaC1k....) to the second window. | ||
- | * press the " | ||
- | * Try to connect to **lth.epfl.ch**, |
sshkey.1302012251.txt.gz · Last modified: 2011/04/05 16:04 by cangiani