Illustration of a laptop using SSH keys to connect securely to a remote server
Editor note: This guide is educational and is written for safe server administration. It does not ask readers to share passwords, private keys, hosting credentials, recovery phrases, or machine access details.
Who this guide is for: This article is for website owners, WordPress users, developers, and beginners who need to connect to a hosting account or server without exposing sensitive login details.
Editorial transparency: Prepared by The Infosiast and last reviewed on June 5, 2026. This guide was refreshed to remove vague advice, add safer key-based workflows, and cite official OpenSSH and Microsoft documentation.
SSH stands for Secure Shell. It is a network protocol used to create an encrypted connection between your computer and a remote machine, usually a web server, VPS, cloud instance, or hosting account. In plain language, SSH lets you manage a server from a terminal while keeping the session protected from ordinary network snooping.
The most common command looks simple: ssh username@server-address. Under the surface, the client and server negotiate encryption, verify the server identity, authenticate the user, and then open a protected channel for commands, file transfers, tunneling, or administration. This is why SSH replaced older tools such as Telnet, which sent information in a much less protected way.
What SSH is used for
SSH is useful whenever you need secure remote access. A WordPress site owner might use it to run WP-CLI, create a database backup, check file permissions, or inspect error logs. A developer might use it to deploy code, connect to Git, tunnel a database connection, or copy files with SCP or SFTP. A system administrator might use it for patching, log review, user management, and automation.
SSH is powerful, so it should be treated with care. If someone gets your private key, hosting password, or active terminal session, they may be able to control the server with your permissions. The goal is not just to “make SSH work.” The goal is to make it work in a way that limits risk.
How SSH authentication works
SSH can authenticate a user with a password, a key pair, or another configured method. Password access is easy to understand, but it is often weaker because passwords can be guessed, reused, phished, or typed into the wrong place. Key-based access is usually safer when it is set up properly.
An SSH key pair has two parts. The public key can be placed on the server. The private key stays on your own computer and should never be pasted into a chat, email, document, support ticket, or website form unless you are absolutely sure what you are doing. When you connect, the server can verify that your private key matches the public key without the private key leaving your machine.
Safer first-time SSH setup
For temporary access, create a new key just for that task. Do not reuse your main personal key everywhere. A dedicated key can be removed later without breaking other projects.
ssh-keygen -t ed25519 -f ~/.ssh/site-temp-access -C "site-temp-access"
This creates a private key and a public key. The file without .pub is private. Keep it on your computer. The file ending in .pub is public. That is the one you add to your hosting account or to the server’s authorized_keys file.
After the public key is installed, connect with the key and the correct port:
ssh -i ~/.ssh/site-temp-access -p 65002 username@server-ip
Replace the username, server address, port, and key path with your actual details. If you are using Windows, PowerShell and recent Windows versions include an OpenSSH client, while Git Bash also works for many users.
How to verify the server before logging in
The first time you connect, SSH may show a host-key fingerprint and ask whether you trust the server. This prompt matters. It is designed to reduce the chance of connecting to an impostor server. If your hosting dashboard provides the server fingerprint, compare it before accepting. If you cannot verify the fingerprint, at least confirm the IP address and hostname from your hosting panel rather than from a random message or screenshot.
If SSH warns that a host key changed, stop and investigate. A changed host key can happen after a server rebuild, but it can also indicate a man-in-the-middle risk. Do not blindly accept the new key when the server controls valuable files or databases.
Practical SSH security habits
- Use a unique key per project or client. This keeps cleanup simple if access is no longer needed.
- Protect the private key with a passphrase. A passphrase adds another layer if the key file is copied.
- Remove temporary public keys after the work is done. Leaving old keys active creates unnecessary entry points.
- Do not share private keys or hosting passwords in chat. Share only the public key if someone needs to add access.
- Prefer least privilege. Use a user account that only has the permissions needed for the task.
- Keep your local machine clean. Malware on your computer can steal keys, sessions, browser cookies, and saved passwords.
SSH commands beginners should know
These are common commands used after a successful login:
pwdshows the current directory.ls -lalists files, including hidden files.cd folder-namechanges directory.wp plugin listlists WordPress plugins when WP-CLI is installed and you are in the WordPress path.exitcloses the SSH session.
Be extra careful with commands that delete, move, overwrite, or recursively change permissions. A command such as rm -rf or a broad permission change can damage a site quickly if it is run in the wrong directory.
SSH file transfer options
SSH also supports secure file transfer. scp copies files between local and remote machines. sftp gives an interactive file transfer shell. Many hosting panels and desktop apps use SFTP because it is easier to use than raw command-line copying.
For WordPress work, SSH and SFTP are often safer than editing files in the WordPress dashboard. If a plugin editor or theme editor breaks PHP code, the admin panel can become unreachable. SSH access gives you a way to inspect logs, revert a file, or disable a plugin folder when the dashboard is down.
Common SSH mistakes to avoid
- Using the same private key for every site and never rotating it.
- Saving private keys in cloud folders that sync broadly across devices.
- Adding a public key to a hosting account and forgetting to remove it after the job.
- Accepting host-key warnings without checking the server details.
- Running copied terminal commands without understanding the current directory.
- Giving full hosting or root access when a limited SSH user would be enough.
SSH key safety for WordPress site owners
For a WordPress site owner, SSH is often used only when something important is happening: backups, migrations, plugin fixes, malware cleanup, WP-CLI commands, or emergency recovery. That makes the access valuable. Treat SSH access like a temporary power tool, not like a casual login you leave open forever.
The safest pattern is to create a dedicated SSH key for one site or one project, add only the public key to the hosting account, use it for the job, and remove it afterward if ongoing access is not needed. This approach limits damage if the key must be rotated later. It also avoids sharing a single private key across many unrelated sites.
Private key vs. public key
The public key is safe to place in your hosting dashboard. The private key is the sensitive file that proves you are the person who owns that public key. Never paste the private key into a chat, support ticket, form, email, or document. If someone needs to give you access, send them the public key only.
For a temporary WordPress task, a good naming habit helps you remember why the key exists:
ssh-keygen -t ed25519 -f ~/.ssh/example-site-temp -C "example-site-temp"
After the job is finished, remove the public key from the hosting account or server. You can keep the private key locally if you expect to use it again, but if it was truly temporary, deleting it after removing server access is cleaner.
Use an SSH config file for fewer mistakes
Typing a long command every time increases the chance of connecting to the wrong user, host, key, or port. A local SSH config entry can reduce that risk:
Host example-site
HostName 203.0.113.10
User site-user
Port 65002
IdentityFile ~/.ssh/example-site-temp
IdentitiesOnly yes
Then you can connect with:
ssh example-site
The IdentitiesOnly yes setting helps ensure the client uses the key you named instead of trying unrelated keys from an agent.
File permissions and private keys
On Unix-like systems, SSH may refuse to use a private key if permissions are too open. A common safe setting is readable only by your user account:
chmod 600 ~/.ssh/example-site-temp
On Windows, keep the key in your user profile, not in a shared folder. Avoid storing it in locations that sync to many devices unless you understand the risk. If your machine is shared, stolen, or infected, private keys can become a serious security exposure.
Agent forwarding: useful, but risky
SSH agent forwarding lets a remote server use your local SSH agent to connect somewhere else, such as a Git host. The OpenSSH manual warns that agent forwarding should be enabled with caution. If the remote host is compromised, attackers may be able to use the forwarded agent during your session even though they cannot directly copy the private key material.
For routine WordPress hosting work, avoid agent forwarding unless you truly need it. If you need to reach another system through a server, a jump host or explicit deploy key may be safer and easier to audit.
Port forwarding safety
SSH can forward ports, which is useful for private databases, admin panels, or local testing. It is also easy to misuse. When forwarding a service, bind it to localhost unless you intentionally want other machines to reach it. A local-only tunnel reduces accidental exposure.
ssh -L 127.0.0.1:3307:127.0.0.1:3306 example-site
This example makes a remote database available on your own machine at a local port. It does not publish the database to the internet. Still, only use tunnels when you understand what service is being exposed and who can access the local port.
A safe WordPress SSH workflow
- Confirm the host, username, and port from the hosting dashboard.
- Create a dedicated temporary key.
- Add only the public key to the hosting account.
- Connect and verify the WordPress path with
pwdandls. - Run read-only commands first, such as
wp plugin listorwp core version. - Create a file and database backup before changes.
- Make one meaningful change at a time.
- Verify the public site after each risky change.
- Remove temporary access when the work is done.
What to do if a key may be exposed
If you accidentally paste a private key somewhere, assume it is compromised. Remove the matching public key from every server where it was installed. Generate a new key pair. Check recent logins where your host provides logs. If the server contains sensitive customer data, payment data, or production credentials, consider a broader incident review.
Do not rely on deleting the message alone. Once a private key has been shared outside your control, rotation is the safer choice.
Server-side SSH hardening checklist
If you control the server configuration, SSH can be hardened further. On managed shared hosting, you may not have access to every setting, but on a VPS or dedicated server these controls are worth reviewing.
- Disable root login: Use a normal user with sudo where needed instead of logging in directly as root.
- Prefer key authentication: Password-only SSH is easier to attack through guessing and credential reuse.
- Remove old keys: Audit
authorized_keysafter staff changes, contractor work, migrations, and emergency support sessions. - Limit users: Only users who need shell access should have shell access.
- Use firewalls where possible: Restrict SSH to trusted IP ranges if your workflow supports it.
- Keep OpenSSH updated: Security improvements often depend on newer client and server versions.
- Monitor login logs: Repeated failed attempts, logins from unusual locations, or unexpected user activity deserve attention.
Understanding SSH warnings
Sometimes SSH shows warnings about host keys, changed fingerprints, or key exchange algorithms. Do not treat these as decoration. They exist because SSH security depends on verifying that you are talking to the right server and using a reasonably strong cryptographic handshake.
A warning about a changed host key can be serious. It may happen after a legitimate server rebuild, but it can also indicate that the server identity is not what your machine expected. A warning about older key exchange algorithms usually means the server supports a weaker or less modern negotiation method. It does not automatically mean an attacker is present, but it is a reason to ask the host whether OpenSSH can be upgraded or configured more securely.
WP-CLI commands to run carefully over SSH
WP-CLI is one of the best reasons for WordPress site owners to use SSH. It can inspect plugins, clear caches, create users, export databases, and repair problems when the dashboard is not available. The power is useful, but commands should be staged carefully.
wp core version
wp plugin list
wp theme list
wp option get siteurl
wp db size
wp search-replace old.example.com new.example.com --dry-run
The --dry-run flag is important for search-replace operations because it shows what would change before changing the database. Similarly, create a database export before any migration, bulk replace, plugin cleanup, or content operation.
Dangerous command patterns
Be cautious with commands that include wildcards, recursion, deletion, or permission changes. The difference between deleting a cache folder and deleting a WordPress content folder can be one path typo. The same caution applies to chmod -R and chown -R. Broad permission changes can break uploads, expose files, or create security problems.
When cleaning cache, confirm the exact cache path first. When moving files, list both source and destination. When deleting, avoid running from a directory you have not verified with pwd. Slow is fast when the command can damage a site.
When SSH is safer than browser automation
For WordPress maintenance, SSH is usually safer than controlling a logged-in browser for bulk work. Browser automation depends on sessions, cookies, UI state, and plugin screens that can change. SSH with WP-CLI can be more explicit: the command says what will happen, and the output can be logged.
That does not mean SSH is risk-free. It means the risk is easier to scope when you use a temporary key, limited user, backups, and clear commands. For content editing, WordPress APIs and WP-CLI are often more reliable than clicking through dozens of admin pages.
SSH troubleshooting FAQ
- Permission denied: Check the username, key path, public key installation, and whether the server allows key login for that account.
- Connection timed out: Check the host, port, firewall, hosting SSH status, and whether the server is reachable from your network.
- Host key verification failed: Check whether the server was rebuilt or whether your known-hosts entry is outdated. Do not bypass the warning until you understand why it appeared.
- Too many authentication failures: Your SSH agent may be offering many keys. Use
IdentitiesOnly yesor specify the correct key explicitly. - WP-CLI command not found: Your host may not have WP-CLI in the default path, or you may not be inside the WordPress directory.
When to remove SSH access
Remove SSH access when a contractor finishes, when a migration is complete, when a key was created only for one emergency, when an employee leaves, or when you cannot explain why a key is still present. Access that exists “just in case” becomes a future risk.
A quarterly access review is a good habit. Check hosting users, SSH keys, FTP/SFTP accounts, WordPress administrators, database users, and connected services. Many site compromises begin with old access that nobody remembered to remove.
Related guides
Sources
- OpenBSD manual: ssh
- OpenBSD manual: ssh-keygen
- OpenBSD manual: sshd_config
- Microsoft Learn: Get started with OpenSSH for Windows
Bottom line
SSH is one of the safest ways to manage a server when it is used with care. Use a dedicated key, protect the private key, verify the server, limit permissions, and remove temporary access when the job is finished. The technology is strong, but the real security comes from disciplined habits around keys, commands, and access.