howto:sshkey
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
howto:sshkey [2025/07/08 23:20] – jnilsson | howto:sshkey [2025/07/22 17:42] (current) – [Ask for help from SSCS] jnilsson | ||
---|---|---|---|
Line 2: | Line 2: | ||
===== Generating keys ===== | ===== Generating keys ===== | ||
=== ssh-keygen === | === ssh-keygen === | ||
- | You use the tool " | + | You use the tool "**ssh-keygen**" to create your public-private key pair. Here is an example session showing how you can run ssh-keygen: |
<code bash> | <code bash> | ||
[user@host ~]$ ssh-keygen -t ed25519 -C "Add a Description to easily tell which machine this belongs to" | [user@host ~]$ ssh-keygen -t ed25519 -C "Add a Description to easily tell which machine this belongs to" | ||
Line 10: | Line 10: | ||
Enter same passphrase: [Enter to leave empty] | Enter same passphrase: [Enter to leave empty] | ||
</ | </ | ||
- | You should leave the default values above by simply hitting Enter three times. | + | You should leave the default values above by simply hitting |
===== Distributing your public key ===== | ===== Distributing your public key ===== | ||
Line 18: | Line 18: | ||
There are different ways to distribute and set up the authorized_keys file depending on your situation: | There are different ways to distribute and set up the authorized_keys file depending on your situation: | ||
+ | |||
+ | ==== Ask for help from SSCS ==== | ||
+ | |||
+ | You can always ask for help from [[socit@uci.edu]] and we'll work with you to get your public key set up. | ||
+ | |||
+ | If you want to DIY, you can try one of the methods below: | ||
==== Local Console Access ==== | ==== Local Console Access ==== | ||
Line 24: | Line 30: | ||
- Save the .pub key file either in email to yourself or on a USB drive | - Save the .pub key file either in email to yourself or on a USB drive | ||
- On the local console of the remote host, login as your user account: | - On the local console of the remote host, login as your user account: | ||
- | - Copy the contents of the new public key (either from email or a USB drive) to a temp file:< | + | - Copy the contents of the new public key (either from email or a USB drive) to a temp file:< |
TMP_NEWKEY_FILE=/ | TMP_NEWKEY_FILE=/ | ||
echo " | echo " | ||
</ | </ | ||
- | - Set up your ~/.ssh directory and authorized_keys file with correct permissions. This is safe to do even if they already exist and will not erase or overwrite existing keys:< | + | - Set up your ~/.ssh directory and authorized_keys file with correct permissions. This is safe to do even if they already exist and will not erase or overwrite existing keys:< |
mkdir -p ~/.ssh | mkdir -p ~/.ssh | ||
touch ~/ | touch ~/ | ||
Line 34: | Line 40: | ||
chmod 600 ~/ | chmod 600 ~/ | ||
</ | </ | ||
- | - Append your new public key:< | + | - Append your new public key:< |
cat $TMP_NEWKEY_FILE >> ~/ | cat $TMP_NEWKEY_FILE >> ~/ | ||
</ | </ | ||
- | - Delete the temp file:< | + | - Delete the temp file:< |
rm $TMP_NEWKEY_FILE | rm $TMP_NEWKEY_FILE | ||
</ | </ | ||
Line 73: | Line 79: | ||
If password authentication is already disabled, then you will have to give your public key file to someone with admin access who already has public key authentication set up, or follow the above instructions for local console access to set it up yourself. | If password authentication is already disabled, then you will have to give your public key file to someone with admin access who already has public key authentication set up, or follow the above instructions for local console access to set it up yourself. | ||
- | If you have admin access and have been asked to add someone else's public key to their user account, the following example code should guide you on the steps to take. This assumes that they have somehow given you their public key and it is stored in a file called / | + | If you have admin access and have been asked to add someone else's public key to their user account, the following example code should guide you on the steps to take. This assumes that they have somehow given you their public key and it is stored in a file called / |
- | < | + | < |
USERNAME=example | USERNAME=example | ||
TMP_PUBKEY_FILE="/ | TMP_PUBKEY_FILE="/ |
howto/sshkey.1752016857.txt.gz · Last modified: 2025/07/08 23:20 by jnilsson