# Getting SSH keys to work
## Generationg SSH keys
---
In Linux and macOS SSH keys can be generated in cmd by command:
ssh-keygen -t rsa
In Windows SSH keys can be generated in powershell by command:
ssh-keygen.exe -t rsa
The program prompts the user through the process, just sets the location and asks the user to set a passphrase, which should be created. This process ends with two keys in the path it showed. One of them is named (by default) `id_rsa` and the other `id_rsa.pub`. The `.pub` key is your public key, the other is a private key.

More detail guides can be found here:
- Linux - [https://linuxhint.com/generate-ssh-keys-on-linux/](https://linuxhint.com/generate-ssh-keys-on-linux/)
- macOS - [https://docs.tritondatacenter.com/public-cloud/getting-started/ssh-keys/generating-an-ssh-key-manually/manually-generating-your-ssh-key-in-mac-os-x](https://docs.tritondatacenter.com/public-cloud/getting-started/ssh-keys/generating-an-ssh-key-manually/manually-generating-your-ssh-key-in-mac-os-x)
- Windows - [https://phoenixnap.com/kb/generate-ssh-key-windows-10](https://phoenixnap.com/kb/generate-ssh-key-windows-10)
***NB! Never share your private key with anyone.***
## Uploading SSH keys to base
---
Once the keys are created, the public (.pub) key needs to be uploaded to base. There are a couple of ways to do it. On base, SSH public keys are found in `/etc/AuthorizedKeys/$USER` file, there is a link to it from `.ssh/authorized_keys` file.
Several SSH keys can be used simultaneously to access the same user account in case of use several different devices.
On Mac and Linux to copy keys to the cluster:
ssh-copy-id Uni-ID@base.hpc.taltech.ee

On windows it can be copied in powershell with this command:
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh Uni-Id@base.hpc.taltech.ee "cat >> .ssh/authorized_keys"
A more thorough explanation with an example can be found [here](https://www.chrisjhart.com/Windows-10-ssh-copy-id/).