Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 2.08 KB

File metadata and controls

43 lines (35 loc) · 2.08 KB

Create-SSH-Key-on-Local

Introduction

An SSH (Secure Shell) Key is a more secure authentication method compared to passwords when accessing a remote server. With an SSH Key, you can log into the server without typing a password every time. This article will guide you through creating an SSH Key on a local PC.

Requirements

Before starting, make sure you have:

  • A PC or laptop with Windows, macOS, or Linux
  • Access to a terminal or Command Prompt
  • OpenSSH installed on your system (it is available by default on macOS and Linux and can be installed on Windows)

1. Steps to Create an SSH Key

  1. Open the Terminal or Command Prompt
  • Windows: Use PowerShell or Command Prompt (cmd).
  • macOS & Linux: Open the Terminal. image

2. Run the Command to Generate an SSH Key

Enter the following command in the terminal:

ssh-keygen -t rsa -b 4096 -C "email@example.com"

Change “email@example.com” with your main email Explanation of the command:

  • -t rsa: Uses the RSA algorithm
  • -b 4096: Sets the key length to 4096 bits (more secure)
  • -C "email@example.com": Adds a comment for key identification

3. Specify the Storage Location

After running the command above, you will be asked to specify the storage location. By default, the key will be saved in ~/.ssh/id_rsa. If a key with this name already exists, you can rename it or overwrite it.

4. Enter a Passphrase (Optional)

You will be prompted to enter a passphrase (an additional password for security). If you do not want to use a passphrase, simply press Enter.

5. Verify the Generated Key

Once the process is complete, two files will be created in ~/.ssh/:

  • id_rsa (private key, do not share this!)
  • id_rsa.pub (public key, can be shared with the server) image

Conclusion

Using an SSH Key enhances security compared to password-based authentication. Be sure to keep your private key safe and only share the public key with the servers you want to access.

Happy coding!