For the longest time, anytime I wanted to create SSH keys on my local machine and publish them on a server, I'd go through this manual process.
Step 1 - Create an SSH Key
This command creates a public key (id_rsa.pub) and a private key (id_rsa) in the ~/.ssh/ directory.
Step 2 - Manually Copy to Remote Server
After generating the keys, I'd log into the remote server and manually copy the keys using the following commands:
# Double-check authorized keys
# Create an SSH key
# Copy private key to your local computer
cp .ssh/id_rsa > /path/to/local/computer
# Remove private key from the current location
rm -rf .ssh/id_rsa
# View the public key
# Remove the public key file
rm -rf .ssh/id_rsa.pub
# Paste the public key into authorized keys
New Way - Using ssh-copy-id
Now, there's a more straightforward way to copy your public key to the authorized_keys file on the remote server. Simply use ssh-copy-id:
# Generate SSH Key (if not done already)
# Copy Public Key to Remote Server
This streamlined approach eliminates the manual steps of copying and pasting keys, making the process more efficient and user-friendly.
The link has been copied!
Subscribe to new posts
Processing your application
Please check your inbox and click the link to confirm your subscription
There was an error sending the email
You’ve successfully subscribed to Chris Mendez
Welcome back! You’ve successfully signed in.
Great! You’ve successfully signed up.
Success! Your email is updated.
Your link has expired
Success! Check your email for magic link to sign-in.