# Idea It's safer and easier to use RSA key to login to servers (instead of entering passwords). Step 1. Generate private and public keys (key pair) on your local machine. **If you already have generated an RSA key previously, you can skip this step**. See location of keys section below. Note that if you already have an RSA key, you'll see a message asking you whether you want to overwrite it—usually you can reuse your key so you should cancel and skip so you don't overwrite. ```sh # geenerate RSA key pair on your local machine ssh-keygen -t rsa ``` Step 2. Then copy your public key to your server/node. Use `ssh-copy-id` to copy/upload your public key to your server/node. ```sh # replace [email protected] with your actual username and ip address of your server ssh-copy-id [email protected] # example ssh-copy-id [email protected] ``` ## Location of keys Keep your **private** key on your local machine. It's **private**, so don't share it with anyone! Locations of keys: ```sh # private key location (KEEP IT PRIVATE)! /home/user/.ssh/id_rsa cd ~/hause/.ssh # public (will be uploaded to server) /home/user/.ssh/id_rsa.pub ``` # References - [How To Set-Up SSH Keys – Linux | E2E Networks Knowledgebase](https://www.e2enetworks.com/help/knowledge-base/set-up-ssh-keys/) - [Using SSH Keys to Support Multi-node Compute Tools & Scripts - School of Computer Science](https://carleton.ca/scs/2021/using-ssh-keys-to-support-multi-node-compute-tools/)