Both sides previous revisionPrevious revisionNext revision | Previous revision |
other:ssh [2024/11/28 15:31] – [Installing ssh keys] Improved jypeter | other:ssh [2024/11/29 13:58] (current) – [Installing ssh keys] Improved jypeter |
---|
<note tip>**Special case**: | <note tip>**Special case**: |
| |
* ''spirit[x]'' servers: if you need to use the [[other:ssh#ipsl_servers|IPSL spirit[x] servers]], you had to send your //public// key when you requested your account, and the IT people will take care of putting your //public// key in the correct place when they create your account | * ''spirit[x]'' servers: if you need to use the [[other:ssh#ipsl_servers|IPSL spirit[x] servers]], you have to send your //public// key when you request your account, and the IT people will take care of putting your //public// key in the correct place when they create your account |
| |
</note> | </note> |
| |
The **required //ssh key// files have to be present in the ''.ssh'' [[other:ssh#configuration_files|directory where ssh stores its configuration files]]**, on the //source// **and** //target// computers. We assume that you have copied the required key files in the ''.ssh'' directory of both source and target computers. | The **required //ssh key// files have to be present in the ''.ssh'' [[other:ssh#configuration_files|directory where ssh stores its configuration files]]**, on the //source// **and** //target// computers. You do not need the same key files on the //source// **and** //target// computers, but it is easier to have all the key files in all the ''.ssh'' directories. This will also act as a backup of the key files in different locations. |
| |
| |
* on the **//source// computer**\\ (your local desktop/laptop, or a remote Linux server if you will use ssh/scp from this remote server to another remote server) | We assume below that you have copied the required key files in the ''.ssh'' directory of both //source// and //target// computers. We also assume that we are dealing with ''ed25519'' keys, so the //key// files will are named: ''id_ed25519'' (and ''id_ed25519**.ppk**'' on a Windows computer, if you use [[other:putty_conf#using_ssh_keys_with_putty_pageant|PuTTY/Pageant]]), and ''id_ed25519**.pub**''. |
* you need the //private// key: e.g. ''id_ed25519'' (and ''id_ed25519.ppk'' on a Windows computer, if you use [[other:putty_conf#using_ssh_keys_with_putty_pageant|PuTTY/Pageant]]) | |
| |
| * on the **//source// computer**\\ (your local desktop/laptop, or a remote Linux server if you will use ''ssh''/''scp'' from this remote server to another remote server)\\ \\ |
| * you need **the //private// key**: e.g. ''id_ed25519'' |
* remember that **the private key has to be readable only by the file owner (you!)** on a linux (or Mac) computer\\ <code>$ chmod 600 ~/.ssh/id_ed25519 | * remember that **the private key has to be readable only by the file owner (you!)** on a linux (or Mac) computer\\ <code>$ chmod 600 ~/.ssh/id_ed25519 |
| |
$ ls -l ~/.ssh/id_ed25519 | $ ls -l ~/.ssh/id_ed25519 |
-rw------- [...] /some_path/your_login/.ssh/id_ed25519</code> | -rw------- [...] /some_path/your_login/.ssh/id_ed25519</code> |
| |
| |
* and the **//target// computer**\\ (a remote Linux server) | * and the **//target// computer**\\ (a remote Linux server)\\ \\ |
* you need the //public// key: ''id_ed25519.pub'' | * you need **the //public// key**: e.g. ''id_ed25519.pub'' |
* you need a copy of the //public// key in the ''authorized_keys'' file | * you need a copy of the //public// key in the ''authorized_keys'' file |
* if the ''authorized_keys'' file does not exist yet, just copy the //private// key file\\ <code>$ cd ~/.ssh | * **if the ''authorized_keys'' file does not exist yet**, just copy the //public// key file\\ <code>$ cd ~/.ssh |
$ ls -l authorized_keys | $ ls -l authorized_keys |
ls: cannot access authorized_keys: No such file or directory | ls: cannot access authorized_keys: No such file or directory |
| |
$ cp -p id_ed25519.pub authorized_keys</code> | $ cp -p id_ed25519.pub authorized_keys</code> |
* if there is already an ''authorized_keys'' file (possibly with older public keys), just add the new public key to the file | * **if there is already an ''authorized_keys'' file** (possibly with older public keys), just create a backup of the existing file, and **add the new public key at the end of the file**\\ <code>$ cd ~/.ssh |
| |
| $ cat authorized_keys |
| ssh-dss AAAAB3NzaC1kc3MAAACBAM9w0bY604COfD5yLwlBLaSDSbi2eKfhPJBl/ |
| [...] |
| OUZ8jrQrhDbq2P7GNTTaEEdy+JvtDvZSZLG4+DwhWSkxqPZ35yD8wfOi5WInpG3Cms some_login |
| |
| $ mv authorized_keys authorized_keys.save |
| |
| $ cat authorized_keys.save id_ed25519.pub > authorized_keys |
| |
| $ cat authorized_keys |
| ssh-dss AAAAB3NzaC1kc3MAAACBAM9w0bY604COfD5yLwlBLaSDSbi2eKfhPJBl/ |
| [...] |
| OUZ8jrQrhDbq2P7GNTTaEEdy+JvtDvZSZLG4+DwhWSkxqPZ35yD8wfOi5WInpG3Cms some_login |
| ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIICD35IUxzgjlslHsrOZQ2ARZsXN1RuDcJ+ncyBKLwHr another_login |
| </code> |
==== Using the keys ==== | ==== Using the keys ==== |
| |