SSH keys provide a safer, repeatable way to access a web hosting account without sharing passwords. This guide covers how to set up SSH key access, verify it, rotate a key without losing access, remove access when a device or team member is no longer trusted, and recover from common SSH permission denied errors.
Overview
SSH, or Secure Shell, is a command-line protocol used to connect to a server and run commands remotely. On compatible cloud hosting, VPS, and some managed or shared hosting plans, SSH keys authenticate a user through a matched pair: a private key kept on your device and a public key uploaded to the hosting account or server.
The private key should never be uploaded, emailed, pasted into a ticket, or committed to a repository. The public key is designed to be shared with the server. During login, the server checks whether your private key matches an approved public key. A password does not need to travel across the connection for this authentication method.
Exact steps vary by operating system, hosting control panel, account type, and server configuration. Before changing anything, confirm that your plan supports SSH, identify the correct username and hostname, and check which key algorithms the provider accepts. A hosting control panel may let you import or authorize a key, while a cloud VPS may require you to edit ~/.ssh/authorized_keys or use an administrator account.
Key-management options
| Approach | Best fit | Trade-off |
|---|---|---|
| One key per person and device | Small teams and individual administration | More keys to inventory and remove |
| Separate deployment key | Automated deployments or a staging workflow | Requires careful scope and secret storage |
| Centralized access management | Organizations with many users or servers | Needs compatible infrastructure and administration |
| Shared private key | Generally avoid | Attribution, rotation, and offboarding become difficult |
For most teams, a separate key for each person and device is the clearest starting point. It makes an access review useful because each authorized public key can be connected to a specific owner.
Checklist by scenario
Set up SSH key hosting access
- Confirm the access details. Record the hosting hostname, SSH port if it is not the default, account username, and the directory you should reach after login. Do not assume the username is the same as your control-panel email address.
- Generate a key on the device that will connect. On macOS, Linux, or a current Windows terminal, a typical command is
ssh-keygen -t ed25519 -C 'name-device-purpose'. If the provider does not support Ed25519, use the algorithm recommended in its documentation, such as RSA with an appropriate key length. - Protect the private key. Save it in your user SSH directory, use a passphrase, and keep the private-key file private. An SSH agent can store the unlocked key temporarily so you do not need to enter the passphrase for every connection.
- Upload only the public key. The public key normally ends in
.pub. Import it in the hosting panel, paste it into the provider's SSH-key field, or append it to the target account's~/.ssh/authorized_keysfile if you administer the server. - Authorize the key if required. Some panels separate importing a key from enabling it. Complete both steps if the interface provides them.
- Test a new session. Keep the control panel or an existing administrative session open while testing. Connect with a command such as
ssh -i ~/.ssh/id_ed25519 username@example-host. Once connected, verify the account, home directory, and permissions before running deployment or maintenance commands.
Rotate a key without interrupting access
Rotation means replacing an existing key with a new one. It is useful after a device replacement, suspected exposure, a change in responsibilities, or a scheduled access review.
- Generate the replacement key on the approved device and label it clearly.
- Add the new public key while the old key still works.
- Open a separate terminal and test the new key explicitly with the
-ioption or an SSH configuration entry. - Confirm that automated jobs, deployment tools, and backup scripts do not still depend on the old private key.
- Remove the old public key from the hosting panel or
authorized_keysfile. - Test again after removal, then record the rotation date, owner, and affected systems.
Never remove the old key first unless you have another verified administrative path. On a remote server, an untested replacement can turn a routine rotation into a recovery task.
Remove SSH access
When a person leaves a project or a device is lost, identify every key associated with that person or device. Remove the corresponding public key from each hosting account, VPS, deployment system, and automation service. If the account itself is no longer needed, disable or delete it according to your provider's controls.
After removal, test from a separate session using the old key if your security process permits it. A failed authentication confirms that the old credential no longer works, but do not repeatedly test a key if the provider has login-rate limits or an intrusion-prevention system. Also review control-panel access, SFTP users, API tokens, repository deploy keys, and saved credentials; removing an SSH key does not remove those other access paths.
Recover from a rejected key
If login fails, first use verbose output to identify where the failure occurs: ssh -v -i ~/.ssh/id_ed25519 username@example-host. Check that the client is using the intended key, the hostname and username are correct, and the key is authorized in the panel. If you still have console, control-panel terminal, or another administrator session, inspect the account's SSH configuration and restore the public key carefully.
What to double-check
- Provider support: Shared hosting may restrict shell commands, ports, or available shells. Cloud hosting and VPS plans usually provide more control, but the provider's documentation remains authoritative.
- Algorithm compatibility: Use a modern algorithm supported by both the client and server. If a legacy system requires another option, document the exception and plan a future change.
- File ownership and permissions: On a Linux server, the SSH directory commonly belongs to the target user and is not writable by other users. A typical baseline is
700for~/.sshand600forauthorized_keys, but hosting environments may apply different requirements. Incorrect ownership or overly broad permissions can cause the server to reject an otherwise valid key. - Private-key protection: Check that the private key is not inside a public web directory, backup shared with untrusted users, source repository, or support attachment. Use a passphrase and restrict local file access.
- Least privilege: Connect with a non-root user when possible. Grant only the permissions needed for deployment or maintenance, and use a separate administrative path for exceptional tasks.
- Automation: Store deployment keys in the CI/CD system's secret store, restrict their scope, and avoid reusing a personal key in automation.
- Backups and recovery: Keep a documented recovery route, such as provider console access or a second verified administrator. Do not treat a backup of a private key as a substitute for an access inventory.
For related infrastructure work, coordinate SSH changes with your staging and production workflow. If a deployment changes DNS or SSL configuration, review the relevant DNS records guide and SSL troubleshooting checklist separately.
Common mistakes
- Uploading the private key: The server needs the public key. Treat any exposed private key as compromised and replace it immediately.
- Deleting the only working key: Add and test a replacement before removing the old credential.
- Using the wrong account: A key authorized for one hosting user does not automatically authorize another user on the same server.
- Copying a key with line breaks or missing text: A public key should remain one complete line in
authorized_keys. Re-copy it from the original file if it appears truncated. - Ignoring the SSH agent: The client may offer a different key than intended. Specify the identity file during diagnosis and review your SSH configuration.
- Changing permissions blindly: Commands copied from a VPS guide may not suit managed or shared hosting. Confirm ownership and provider requirements before modifying files.
- Forgetting non-interactive access: Removing a developer's key may not affect a deployment key, cron job, backup process, or API credential using the same server.
When to revisit
Make SSH access part of a repeatable infrastructure checklist rather than a one-time setup. Revisit it before a new server goes live, when a developer or administrator joins or leaves, after a device is lost or replaced, and whenever a private key may have been exposed. Include it in seasonal planning cycles and scheduled access audits.
Review the workflow when your hosting provider changes its control panel, supported algorithms, default SSH port, user model, or recovery controls. Operating-system and SSH-client updates can also change key storage, agent behavior, or configuration defaults. Keep this article's commands as examples, then verify the current provider instructions before applying them.
Action checklist: inventory authorized keys, identify each owner, confirm a recovery path, test one key per user and device, remove obsolete credentials, inspect automation separately, and record the date of the review. For a complete launch or migration, combine this access review with the website launch checklist and a tested backup restoration process.