How do I create a public SSH key in Linux?
Andrew Mclaughlin
Updated on February 28, 2026
How to set up SSH keys
- Create the ssh key pair using ssh-keygen command.
- Copy and install the public ssh key using ssh-copy-id command on a Linux or Unix server.
- Add yourself to sudo or wheel group admin account.
- Disable the password login for root account.
How manually install SSH public key?
ssh/authorized_keys file (Where USERNAME is the user in question). If that file doesn’t exist, create it with the command nano ~/. ssh/authorized_keys. With that file open, copy the ssh string into it and then save/close the file.
Where are SSH keys stored RHEL?
By default, your private and public keys are saved in your ~/. ssh/id_rsa and ~/. ssh/id_rsa. pub files, respectively.
Where is public key on Linux server?
By default, the keys will be stored in the ~/. ssh directory within your user’s home directory. The private key will be called id_rsa and the associated public key will be called id_rsa.
How do I add a public key to a remote server?
Setting up public key authentication
- Generate an SSH Key. With OpenSSH, an SSH key is created using ssh-keygen.
- Copy the key to a server.
- Test the new key.
- Troubleshooting.
- Use a passphrase when possible.
- Add a command restriction when possible.
- Managing SSH keys.
- Installation using Homebrew.
How do you create a public key?
How to Create a Public/Private Key Pair
- Start the key generation program.
- Enter the path to the file that will hold the key.
- Enter a passphrase for using your key.
- Re-enter the passphrase to confirm it.
- Check the results.
- Copy the public key and append the key to the $HOME/.
How to set up SSH key on Red Hat Enteprise Linux 8 Server?
The procedure to set up SSH key on Red Hat Enteprise Linux 8 server: 1 On your local desktop type: ssh-keygen 2 Install public key into remote RHEL 8 server using: ssh-copy-id [email protected] 3 Use ssh for password less login: ssh [email protected]
How do I add SSH public keys to a user?
Select Identity → Users. Click the name of the user to edit. Under the Settings tab in the Account Settings area, click SSH public keys: Add. Figure 22.9.
How do I copy SSH keys to a RHEL 8 Server?
You must copy a public SSH key file named ~/.ssh/id_ed25519.pub (or ~/.ssh/id_rsa.pub if you created RSA key) to the RHEL 8 server. Try the ssh-copy-id command as follows: $ ssh-copy-id -i ~/.ssh/ fileNameHere.pub user @ remote-RHEL8-server-ip
What is the difference between OpenSSH_keypair and authorized_key?
The openssh_keypair module uses ssh-keygen to generate keys and the authorized_key module adds and removes SSH authorized keys for particular user accounts. SSH key pairs are only one way to automate authentication without passwords.