Where to find and copy your keys on Windows, Mac, and Linux
The location of your key depends on what kind of key it is and what program created it. SSH keys (used to log into servers) live in a hidden folder called .ssh in your home directory. API keys (used to connect apps to services) are usually shown once when you create them, then stored in your account settings or a configuration file. License keys come in your email or account dashboard. The first step is knowing which type you need and where that service stores it.
Most keys should never be copied to the clipboard or pasted into chat. Instead, you copy them into a file on your own computer, or you let the program that needs them read the file directly. A few services let you copy keys for legitimate reasons — like moving them to a password manager — but the safest approach is to generate a new key in the destination and delete the old one.
Key Takeaways
- SSH keys on Windows, Mac, and Linux are stored in a .ssh folder in your home directory; use File Explorer, Finder, or the terminal to navigate there and open the file with a text editor.
- API keys should be copied directly from your account settings or dashboard into the configuration file or environment variable where the app expects to find them, never into chat or email.
- Most services show API keys only once when you create them; if you lose it, delete the old key and generate a new one rather than trying to retrieve it.
- Never paste keys into a terminal command line where they might be logged in your shell history; instead, store them in a file and let the program read the file.
- If you need to move a key to a new computer, generate a fresh key on the new machine and update the service to use the new one, rather than copying the old key across devices.
Finding SSH keys on your computer
SSH keys are stored in a folder called .ssh inside your home directory. On Windows, Mac, and Linux, your home directory is the folder that opens when you click your username in File Explorer or Finder. The .ssh folder is hidden by default, so you need to show hidden files first.
On Mac: Open Finder, press Command + Shift + Period (full stop). Hidden files will appear. Navigate to your home folder, then look for the .ssh folder. Inside, you will see files named id_rsa, id_ed25519, or similar — these are your private keys. The files ending in .pub are your public keys.
On Windows: Open File Explorer and type %userprofile% in the address bar, then press Enter. This takes you to your home directory. Click View at the top, then check the box next to Hidden Items. Look for the .ssh folder. If it does not exist, you have not yet created an SSH key.
On Linux: Open a terminal and type ls -la ~/.ssh. You will see a list of files in your .ssh folder. The files without .pub in the name are your private keys.
How to open and copy an SSH key safely
Once you have found your key file, open it with a text editor — not Word or Pages. On Mac, right-click the file and choose Open With, then select TextEdit. On Windows, right-click and choose Open With, then Notepad. On Linux, type nano ~/.ssh/id_rsa in the terminal (replace id_rsa with the name of your key if it is different).
The key will look like a long string of characters starting with -----BEGIN OPENSSH PRIVATE KEY----- or -----BEGIN RSA PRIVATE KEY-----. Select all the text (Ctrl+A or Command+A), then copy it (Ctrl+C or Command+C). Do not share this text with anyone. If you need to paste it into a file on another computer, open a text editor there and paste it (Ctrl+V or Command+V), then save the file.
If the service you are connecting to asks for your public key instead, open the file ending in .pub using the same method. Public keys are safe to share — that is their purpose. They start with ssh-rsa or ssh-ed25519.
Finding and copying API keys from your account
API keys are usually found in your account settings or a section called Integrations, Developers, or API. Log into the service's website, look for a settings or account menu, and search for API, Keys, or Tokens. When you find the right page, you will see a button to generate a new key or view an existing one.
Most services show the key only once — after you generate it, you will not be able to see it again. Copy it immediately and paste it into the file or location where you need it. If you close the page without copying it, you will have to delete that key and generate a new one. Some services let you copy the key to your clipboard with a button; others require you to select and copy the text manually.
Never paste an API key into your terminal command line directly. If you do, it may be saved in your shell history, where someone with access to your computer could find it. Instead, store the key in a file (like a .env file or a config file) and let the program read it from there.
Moving keys to a new computer or service
The safest way to move a key to a new computer is not to move it at all. Instead, generate a new key on the new computer and update the service to use the new key. This limits the number of places your key exists and reduces the risk if one copy is compromised.
If you must copy a key to a new computer, use a secure method: encrypt it with a password, transfer it over a secure connection (like SSH or a password manager), and delete the original file once you have confirmed the copy works. Never email a key or paste it into an unencrypted chat.
If you are moving an API key, the better option is to delete the old key in your account settings and generate a new one on the new computer or in the new app. Most services make this easy — you can revoke an old key with one click and create a fresh one in seconds.
What to do if you think your key has been exposed
If you believe someone else has seen your private key or API key, treat it as compromised. Delete it immediately in your account settings or by removing the file from your .ssh folder. Then generate a new key and update any service that was using the old one.
For SSH keys, you will need to update the public key on any server you use it to log into. For API keys, simply delete the old key in your account and generate a new one — the service will automatically start using the new key once you update your configuration.
If the key was used to access sensitive systems (like a cloud server or a financial service), check the activity logs to see if anyone else logged in or made changes. Most services keep a record of when and where a key was used.
Storing keys securely after you copy them
Once you have copied a key, store it in a place where only you can read it. On your computer, this means a file with restricted permissions — on Mac and Linux, you can use chmod 600 filename to make a file readable only by you. On Windows, right-click the file, choose Properties, then Security, and remove access for other users.
For keys you need to use across multiple devices or remember long-term, consider storing them in a password manager like Bitwarden, 1Password, or KeePass. These programs encrypt your keys and let you retrieve them safely when you need them. Never store keys in a shared document, cloud folder, or unencrypted note-taking app.
Frequently Asked Questions
Can I copy my private SSH key to another computer?
You can, but it is safer to generate a new key on the new computer instead. If you must copy it, encrypt the file first, transfer it over a secure connection, and delete the original once the copy is working. Never email or paste a private key into chat.
What if I lost my API key and cannot find it anywhere?
Most services do not let you retrieve a lost API key — you will need to delete the old one and generate a new one. Go to your account settings, find the API or Keys section, and look for a delete or revoke button. Then create a new key and copy it to the location where you need it.
Is it safe to paste my key into a terminal command?
No. If you paste a key directly into a terminal, it may be saved in your shell history, where someone with access to your computer could find it. Instead, store the key in a file and let the program read it from there, or use environment variables.
Where should I store a key after I copy it?
Store it in a file on your computer with restricted permissions (readable only by you), or in a password manager. Never store keys in shared folders, cloud documents, or unencrypted notes. If you need the key on multiple devices, use a password manager to sync it securely.
What is the difference between a private key and a public key?
A private key is secret and should never be shared — it proves your identity. A public key is safe to share — it is used to verify that a message came from you. For SSH, you put your public key on servers you want to log into, and keep your private key on your own computer.