How do I access my SSH public key?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
SSH (Secure Shell) is a protocol used to securely access one computer from another over an insecure network. It makes use of public-key cryptography to authenticate the remote computer and allow the remote user to authenticate themselves. If you are looking to access your SSH public key, the process can slightly vary depending on the operating system you are using. Below, you will find detailed instructions for accessing your SSH public key on various systems.
Accessing SSH Public Key on Linux or macOS
On Linux and macOS, the SSH keys are typically stored in the ~/.ssh directory. Here’s how you can access your SSH public key:
- Open a Terminal Window: You first need to open your terminal. You can find the terminal in your applications folder, or you can search for it.
- Navigate to the SSH Directory: Use the
cdcommand to change the directory to where your SSH keys are stored:
- List the Files in the Directory: To see if you have existing SSH keys, run:
You will typically look for files named id_rsa.pub, id_ecdsa.pub, or id_ed25519.pub, depending on the type of encryption used when the keys were created. The .pub file extension stands for 'public key'.
- Display the Public Key: To display your public key, use the
catcommand followed by the name of your public key file:
Accessing SSH Public Key on Windows
Windows users can access their SSH public keys through the use of PuTTY or Windows 10’s built-in OpenSSH client.
Using PuTTY
- Open PuTTYgen: If you have PuTTY installed, open PuTTYgen from the Start Menu to access your SSH keys.
- Load an Existing Private Key: If you already have a private key, you can load it by clicking on ‘Load’ and browsing to the location of your
.ppkfile. - View the Public Key: Once the key is loaded, you can see the public key in the top pane of PuTTYgen.
Using OpenSSH on Windows 10
- Open PowerShell or Command Prompt: Press
Win + Xand select Windows PowerShell or Command Prompt. - Navigate to the .ssh Directory: By default, SSH stores its files in
C:\Users\YourUsername\.ssh. Change to this directory:
- List and View the Public Key: Use
dirto list all files andtypeto view the public key:
Best Practices and Additional Details
When dealing with SSH keys, it’s important to follow best practices to ensure your keys remain secure:
- Keep Your Private Key Secure: Your private key is the "key" to your server. Do not share it. Keep it safe and secure on your machine.
- Regularly Update and Rotate Keys: Regularly update and change your keys to minimize the risks if they are ever exposed.
- Use a Strong Passphrase: When generating SSH keys, always use a strong passphrase for an extra layer of security.
Summary Table
| Task | Command/Instruction | Note |
| Open Terminal/PowerShell | Terminal/PowerShell | Access through applications or Win + X |
| Navigate to SSH Directory | cd ~/.ssh or C:\Users\YourUsername\.ssh | Change path as needed |
| List SSH Key Files | ls -l or dir | Check existing keys |
| View Public Key | cat <keyname.pub> or type <keyname.pub> | Replace <keyname.pub> with actual file name |
In conclusion, accessing your SSH public key is a straightforward process that can enhance your system’s security when connecting remotely. Whether you are on a Unix-like system or Windows, the steps detailed here will guide you in retrieving your key efficiently and securely. Always remember to handle your SSH keys with care to maintain the integrity of your secure connections.
Related reading
- How do I access my SSH public key?
- How do I add an intermediate SSL certificate to Kubernetes ingress TLS configuration?
- How do I avoid the specification of the username and password at every git push?
- How do I change the publicly accessible option for Amazon RDS?
- How do I connect to mongodb with node.js and authenticate?
- How do I detect that an iOS app is running on a jailbroken phone?
- How do I disable resolving login parameters passed as url parameters / from the url
- How do I disable the security certificate check in Python requests

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.