VPS Tutorials
Connect a Mac to a Linux VPS (2026): a beginner's guide to Terminal SSH login
Make your first Linux VPS SSH connection with macOS Terminal. Enter address, port, username, password or private key, and distinguish network, authentication and host-identity errors.

Use the built-in macOS Terminal to log into a Linux VPS over SSH. Enter the server username, address and port, verify its host fingerprint and use the password or private key specified at provisioning. After connecting, commands in that window run on remote Linux.
This guide assumes an activated Linux VPS. On the first attempt, only log in, identify the machine and log out; deploy applications afterward.
| Detail | Where to confirm | Common confusion |
|---|---|---|
| Connection address | Instance panel or provisioning email | Use this VPS's public IP or specified hostname |
| SSH port | Connection instructions or administrator | Commonly 22; use the actual specified value |
| System username | Image or instance login guidance | May be root, ubuntu or a custom account |
| Credentials | System password or private key matching the registered public key | Provider account, Mac login and server passwords have different purposes |
If both public and private addresses appear, use the public entry point specified for direct access from your home Mac. Instances requiring VPN, a bastion or mapped ports need that access path first. Check address, port and username from the same instance's records.
Press Command + 空格 for Spotlight, search for Terminal or Terminal and open it. Alternatively use Finder → Applications → Utilities. A newly opened window initially runs local Mac commands. Run ssh -V to check the OpenSSH version before continuing. Apple Terminal guide
Suppose provisioning gives username ubuntu, address 203.0.113.10 and port 2222. Use this format, replacing the documentation-only IP with your actual details:
ssh -p 2222 [email protected]
-p is lowercase and followed by the port. Join username and address with @. You can omit -p 22 only when the port is confirmed as 22 and local settings do not override it. Use only hostname or IP, without web protocol or path. Terminal also offers Shell → New Remote Connection; the command makes custom ports and keys easier to check individually. OpenSSH options · Apple server connection guide
If you have used other SSH tools or configured aliases on this Mac, follow ssh with -G to inspect resolved client settings. This prints configuration without making a connection.
ssh -G -p 2222 [email protected]
Among the many lines, find user, hostname and port and compare them with provisioning. Remove -G afterward to connect. For an unexpected port or target, inspect matching settings in local ~/.ssh/config. OpenSSH client configuration
The first connection may ask whether to trust the host and show a fingerprint starting with SHA256:. Compare the same key type through a trusted provider console, administrator or existing trusted record. If it matches, enter yes to save the host identity.
If you cannot verify it, leave the connection and ask the provider. For REMOTE HOST IDENTIFICATION HAS CHANGED on a known server, check reinstallations, IP changes and host-key rotation before changing the old record. Changed host fingerprint troubleshooting
At a prompt such as [email protected]'s password:, enter the server account password and press Enter. The terminal usually shows neither characters nor asterisks. If it fails, check input method, case and spaces introduced by copying. Follow any required first-login password change prompts.
Find the corresponding private key on your Mac. The example assumes it is in .ssh under your user directory and named vps_ed25519. Replace the path with your own. -i selects the key.
ssh -i "$HOME/.ssh/vps_ed25519" -p 2222 [email protected]
Keep the double quotes around the path so spaces work. Enter passphrase for key requests this key's own passphrase. If the terminal explicitly reports overly permissive key-file permissions, run chmod 600 "$HOME/.ssh/vps_ed25519" locally on the Mac after replacing the private-key path. If you only have the .pub public key, recover its paired private key or configure another key through trusted management access. SSH key setup tutorial
The remote prompt often shows a new username and hostname. Run whoami and hostname to verify user and host, then exit to return locally. For simultaneous local and remote windows, open another Terminal tab with Command + T. Check the prompt before acting, especially before deleting, installing or restarting.
| Message | First checks |
|---|---|
Could not resolve hostname | Hostname spelling, an accidentally pasted web URL or DNS |
Connection timed out | Instance status, destination IP and port, security groups and current network access |
Connection refused | Correct target and port, SSH listening there or an active rejection rule |
Permission denied (publickey) | Username and correspondence between registered public and selected private key |
No such identity | File selected by -i exists at the right name and path |
Copy address, port and username from the instance panel again and compare the command to eliminate entry mistakes first. If a firewall or network change locked you out, look for an out-of-band console. Inspect the system there, then verify recovery with a new SSH session from the Mac. VPS web console guide