search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Table of Contents
Frequently Asked Questions
I transferred my SSH key but still get a “Permission Denied” error.
Can I have multiple SSH keys for the same server?
Can I add a new SSH key to a remote server while using an old key?
Home Computer Tutorials Computer Knowledge How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

Apr 06, 2026 am 06:27 AM

If you regularly use SSH to access a remote server, enhancing your SSH security can be achieved by setting up a public/private key pair. This method eliminates the need to send passwords over the network and helps protect against brute force attacks.

On Linux systems, generating an SSH key pair is straightforward.

  1. Launch a terminal and enter:
<code>ssh-keygen -t rsa</code>

Alternatively, you can opt for DSA (Digital Signature Algorithm) instead:

<code>ssh-keygen -t dsa</code>

Note: There's ongoing discussion around the relative security of DSA versus RSA. Unless you're deeply invested in the cryptographic differences, either option works well for general use.

  1. You'll be prompted to choose a location to save the key. By default, it’s stored in the .ssh directory within your home folder. Simply press Enter to use this default path.

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

  1. Next, you’ll be asked to set a passphrase. This isn’t the password for the remote server—it’s a local passphrase to protect your private key. If someone gains access to your private key file, they’ll still need this passphrase to use it. Setting a passphrase is optional; press Enter to skip it.

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

  1. The key generation process will now complete. Use your file manager to go to the .ssh directory. You should see two new files: id_rsa (your private key) and id_rsa.pub (your public key).

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

  1. Transfer your public key to the remote server using this command:
<code>ssh-copy-id username@remote-host-ip-address</code>

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

  1. Now, log into your remote server and open the SSH configuration file:
<code>ssh username@remote-host-ip-address&lt;br&gt;&lt;/br&gt;sudo nano /etc/ssh/sshd_config</code>

Locate the following lines in the file and ensure they are configured as shown:

<code>RSAAuthentication yes&lt;br&gt;&lt;/br&gt;PubkeyAuthentication yes &lt;br&gt;&lt;/br&gt;PasswordAuthentication no</code>

Save the file by pressing Ctrl + O, then exit with Ctrl + X.

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

  1. Restart the SSH service on the remote machine to apply the changes:
<code>sudo systemctl restart ssh</code>

You're all set! You can now connect to your server securely using:

<code>ssh username@remote-host-ip-address</code>

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier

Frequently Asked Questions

I transferred my SSH key but still get a “Permission Denied” error.

This is typically caused by incorrect permissions on the .ssh directory or authorized_keys file on the remote server. The SSH service requires strict permission settings.

Fix this by logging into your remote machine directly and running these commands:

<code>chmod 700 /home/$USER/.ssh &amp;&amp; chmod 600 /home/$USER/.ssh/authorized_keys</code>

Then restart the SSH service:

<code>sudo systemctl restart ssh</code>

Can I have multiple SSH keys for the same server?

Yes, you can. Just make sure each key has a unique name when generating it:

<code>ssh-keygen -f /home/$USER/.ssh/filename</code>

When connecting, specify the correct key:

<code>ssh -i /home/$USER/.ssh/filename [email protected]</code>

Can I add a new SSH key to a remote server while using an old key?

Yes. First, add your new key to the SSH agent:

<code>ssh-add</code>

Then, connect to your old machine using SSH agent forwarding:

<code>ssh -A old.machine.ip.address &amp;&amp; ssh-add -c</code>

Afterward, press Ctrl + D to disconnect from the old machine. You can now use both keys to access the remote server.

Image credit: Unsplash. All modifications and screenshots by Ramces Red.

The above is the detailed content of How to Generate A Public/Private SSH Key in Linux - Make Tech Easier. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Popular tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

6 Tips for Windows 7 End of Life and Support 6 Tips for Windows 7 End of Life and Support Apr 05, 2026 pm 02:51 PM

Windows 7 end of life is fast approaching. This ten-year-old operating system is nearing its final days. While there may be valid reasons you still need or prefer to use Windows 7, once Microsoft discontinues support, the system will become increasin

3 Ways to Reset the Windows 11 Settings App 3 Ways to Reset the Windows 11 Settings App Apr 05, 2026 pm 01:51 PM

The Settings app in Windows 11 lets you easily manage various computer configurations and preferences. Whether you're customizing themes, managing network connections, or checking for system updates, the Windows Settings app is your central hub for system management. If Windows 11's Settings app isn't working properly, or you want to return it to its default state, you can reset it at any time. You can reset the Windows Settings app through the search menu, Command Prompt, or PowerShell. These three methods are described in detail below. How to reset the Windows 11 Settings app through the search menu. The fastest way is to reset the Settings app through the search function of the taskbar. Let’s start with this method.

How To Check For Windows Updates On Windows 10 How To Check For Windows Updates On Windows 10 Apr 06, 2026 pm 01:27 PM

Microsoft allows you to set your Windows computer to check for updates automatically or manually. This post on php.cn will show you how to check for Windows updates on a Windows 10 computer in either way. Besides, it offers some useful solutions to t

4 Simple Methods to Enable True Tone on Mac 4 Simple Methods to Enable True Tone on Mac Apr 04, 2026 pm 01:54 PM

As a Mac user, you may have already experienced the many benefits that True Tone brings. It can automatically adjust the color temperature of the screen according to the light conditions of your environment, bringing a more natural and comfortable visual experience, and effectively reducing visual fatigue caused by long-term use of the device. However, True Tone isn't turned on by default on all Macs, so you may need to enable it manually. Fortunately, macOS provides a variety of ways to turn on True Tone, making it easy for you to enjoy the convenience of this feature. Table of Contents Enabled via Control Center True Tone enabled via System Settings True Tone enabled via Terminal True Tone via Apple S

How to Find the SID of Any User in Windows 11 How to Find the SID of Any User in Windows 11 Apr 07, 2026 pm 02:06 PM

The Security Identifier (SID) is a unique number tied to a user account on a Windows PC. It comes in handy while finding and identifying a user on Windows, and no two SIDs can be identical. The most common means to find a SID on Windows is using t

How to Generate A Public/Private SSH Key in Linux - Make Tech Easier How to Generate A Public/Private SSH Key in Linux - Make Tech Easier Apr 06, 2026 am 06:27 AM

If you regularly use SSH to access a remote server, enhancing your SSH security can be achieved by setting up a public/private key pair. This method eliminates the need to send passwords over the network and helps protect against brute force attacks.

How to Download and Install Google Chrome for Mac How to Download and Install Google Chrome for Mac Apr 05, 2026 pm 02:33 PM

Google Chrome, the popular free cross-platform web browser, is widely used all over the world. If you use a Mac and haven’t installed Chrome yet, or you uninstalled Google Chrome browser and want to reinstall, here is a detailed guide for how to down

How to Cut, Copy, Paste, and Rename Files/Folders in Windows 11? How to Cut, Copy, Paste, and Rename Files/Folders in Windows 11? Apr 17, 2026 pm 02:42 PM

After downloading and installing Windows 11 on your computer, you are not allowed to use the Windows 10 methods to directly cut, copy, paste, rename, and delete a file or a folder via the context menu. Well then, how do these things in Windows 11? No

Related articles