Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Cupertino desk10 min

How to Generate an SSH Key Pair on macOS for Your VPS

A complete macOS Terminal walkthrough for generating an SSH key pair, installing the public key in a VPS account, troubleshooting authentication, and choosing Ed25519 or RSA.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate the key pair in macOS Terminal with ssh-keygen, keep the private key on your Mac, and append only the matching .pub key to the VPS account’s ~/.ssh/authorized_keys. For a current OpenSSH installation, Ed25519 is the practical default:

ssh-keygen -t ed25519 -C "[email protected]"

Protect the private key with a passphrase, install the public key on the correct VPS user, set the server-side permissions to 700 for ~/.ssh and 600 for authorized_keys, then test with ssh [email protected]. This guide explains every step, where macOS stores the files, how to use a named key, and what to check when SSH still asks for a password.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What an SSH key pair does

SSH public-key authentication uses two mathematically related files. The private key proves your identity and must remain on your Mac. The public key can be distributed to servers; it does not let someone derive or use the private key in normal operation.

When you connect, the SSH client offers a public-key identity. The VPS checks whether the corresponding public key appears in the target account’s ~/.ssh/authorized_keys. If it does, the client proves possession of the private key without sending that private key to the server. A password may still be enabled as a separate login method, but a correctly installed key normally lets you authenticate without typing the account password.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

macOS includes the OpenSSH client and the ssh-keygen utility. DigitalOcean’s OpenSSH documentation, last verified 13 July 2026, describes this same workflow. Your VPS provider may use a different username, hostname, port, or server policy, so substitute those values for the examples below.

Choose an algorithm before generating the key

Ed25519: the modern default

Use Ed25519 unless the VPS software is old or its provider specifically requires another algorithm. The command is short, the resulting public key is compact, and it is the modern default in the documented OpenSSH workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

RSA: a compatibility fallback

RSA can be appropriate when a legacy server, older SSH library, or provider control panel does not accept Ed25519. Do not assume RSA is universally better or worse: compatibility depends on the SSH software and policy on the VPS. If you need RSA, generate it explicitly and use a separate filename so it cannot overwrite an existing identity:

ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_vps

The server must support the algorithm and any signature policy required by its SSH version. Check the VPS image documentation when compatibility is uncertain.

Hardware-backed Ed25519 security keys

OpenSSH also supports ed25519-sk, which uses a compatible FIDO authenticator to keep key operations tied to hardware. This is an advanced option, not a prerequisite for ordinary VPS access. Both your Mac’s OpenSSH build and the VPS must support the method, and the authenticator must be available whenever its protection is required.

Generate the key pair in Terminal

  1. Open Terminal. Use Spotlight, Applications › Utilities › Terminal, or another terminal emulator.
  2. Run the Ed25519 command.
    ssh-keygen -t ed25519 -C "[email protected]"

    The comment is a label that helps you identify the key later; it is not a password. Replace the address with a useful label if desired.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Choose the output filename. The command proposes /Users/your-name/.ssh/id_ed25519, represented by the shorthand ~/.ssh/id_ed25519. Press ENTER to accept it when this is a new default identity.
  4. Respond carefully if a file already exists. Do not overwrite a key that may still be used for another server, repository, or service. Enter a new path such as ~/.ssh/id_ed25519_vps2 instead. You can always select that identity later with -i.
  5. Enter a passphrase. Type it when prompted and repeat it. DigitalOcean recommends a passphrase because it protects the private-key file if your Mac is copied or compromised. You can press ENTER to leave it empty, but an unencrypted private key provides less protection if the file is stolen.

On success, ssh-keygen creates two files. The private key is ~/.ssh/id_ed25519; the public key is ~/.ssh/id_ed25519.pub. For a named identity, replace id_ed25519 with the filename you selected. The public file is one line of text that normally begins with ssh-ed25519. Never upload, paste, or email the private file.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Know where macOS stores SSH files

The tilde (~) means your macOS home directory. Therefore:

Item Typical path Purpose
Private Ed25519 key ~/.ssh/id_ed25519 Secret proof held on the Mac
Public Ed25519 key ~/.ssh/id_ed25519.pub Copy this line to the VPS account
Named private key ~/.ssh/id_ed25519_vps2 (example) Separate identity for a particular server or purpose
Named public key ~/.ssh/id_ed25519_vps2.pub Matching public half of the named key

To inspect the directory without displaying the private key, run:

ls -la ~/.ssh

It is safe to display the public key when you are installing it. If you need to inspect its exact one-line contents, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cat ~/.ssh/id_ed25519.pub

Do not run cat on the private-key file in a chat, ticket, web form, or shell transcript that others can read.

Install the public key on the VPS

The public key must be added to the target account’s ~/.ssh/authorized_keys. Uploading the file somewhere else on the VPS, placing it in the wrong user’s home directory, or leaving it only on your Mac does not enable login.

One-command installation when password login works

From your Mac, run this command with the VPS username and address supplied by your provider:

cat ~/.ssh/id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

The first cat reads the public key locally. The pipe sends that line through an SSH session authenticated with your existing password. On the VPS, mkdir -p creates the directory if necessary, and >> appends the key rather than replacing existing keys. Enter the VPS account password when prompted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

For a named key, change only the local filename:

cat ~/.ssh/id_ed25519_vps2.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Using ssh-copy-id

Some macOS setups have ssh-copy-id available, although it is not present in every installation. Where it exists, use:

ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

It performs the same basic task: authenticate with the current method and append the selected public key to the account’s authorized-key file. If the command is unavailable, use the pipe-and-SSH method above or follow your provider’s console instructions.

Manual installation from a provider console

If password SSH is disabled but the VPS offers a web or serial console, open a shell as the target account, create ~/.ssh, and append the complete public-key line to ~/.ssh/authorized_keys. Keep the key on one line; do not add wrapping or omit the key type, encoded key, or comment. The file belongs to the account that will log in, not automatically to the administrative account.

Set permissions that OpenSSH accepts

SSH can reject a key when the account’s SSH directory or authorized-key file is writable by other users. On the VPS, run:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Also verify that the directory and file are owned by the intended login account. If the key is installed under a different account’s home directory, move it to that account’s ~/.ssh/authorized_keys or connect using the account that owns it. Your provider’s image documentation may impose additional SSH restrictions.

The private key on your Mac should likewise be accessible only to you. If macOS reports that the key permissions are too open, restrict the file:

chmod 600 ~/.ssh/id_ed25519

Apply the same command to a named private key, changing the path accordingly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Test key-based login

  1. Run the basic connection command:
ssh [email protected]

Replace user and server.example with the exact VPS account and address. The first connection may show a host-authenticity warning and ask whether you want to continue. Before accepting, compare the displayed fingerprint with the fingerprint shown in your provider’s trusted control panel or console. The available documentation demonstrates the prompt but does not define one universal verification procedure for every provider.

  1. If the key has a non-default filename, identify it explicitly:
ssh -i ~/.ssh/id_ed25519_vps2 [email protected]
  1. After successful authentication, confirm that you reached the expected VPS and account. A shell prompt alone does not prove that you selected the intended server or username.

Once the key works, you can optionally configure an SSH host alias in ~/.ssh/config so you do not have to type -i repeatedly. Keep any configuration entry limited to the host, user, and identity you intend to use, and protect the file from other local users.

Use ssh-agent for passphrase convenience

A passphrase encrypts the private key at rest, but entering it for every connection can be inconvenient. An SSH agent can hold an unlocked key in memory for repeated use during your session. Start or access the agent and add the key:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Enter the key’s passphrase when ssh-add requests it. For a named identity, substitute its path. The agent stores the usable key material for the session according to the agent and macOS behavior; it does not copy the private key to the VPS. Remove a key from the agent when it is no longer needed with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ssh-add -d ~/.ssh/id_ed25519

Agent behavior and persistence can vary by macOS release and shell setup. If you use a shared Mac account, treat an unlocked agent as a sensitive credential.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why SSH still asks for a password

A password prompt can mean either that the key was not offered or that the server rejected it. Work through these checks in order.

Confirm the username and address

The authorized key is valid only for the account in whose home directory it is installed. Check the provider’s exact login username, VPS address, and any nonstandard port. Installing the key for one account and connecting as another produces a public-key failure even when the key text is correct.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Confirm that the complete public key was appended

On the VPS, inspect the target account’s ~/.ssh/authorized_keys and compare the line with the output of cat ~/.ssh/id_ed25519.pub on your Mac. The key type, encoded body, and comment must remain together on one line. Do not accidentally paste the private key or introduce line breaks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check server-side path, ownership, and permissions

Make sure the file is exactly ~/.ssh/authorized_keys for the account you are using, that ~/.ssh is mode 700, and that authorized_keys is mode 600. Verify ownership as well. A key in /root/.ssh/authorized_keys does not authenticate a regular user, and a file owned by the wrong account may be ignored.

See which identity the client offers

Run SSH in verbose mode:

ssh -v [email protected]

The diagnostic output shows the identities the client searches for and offers. Look for your intended private-key path. If it is absent, use -i explicitly:

ssh -v -i ~/.ssh/id_ed25519_vps2 [email protected]

Do not publish verbose output if it contains hostnames, usernames, or other operational details that your organization treats as sensitive.

Do not assume every provider has the same SSH policy

The documented workflow does not establish every VPS provider’s server configuration. An image may disable password login, restrict accepted algorithms, use a custom SSH port, or apply account-specific settings. Consult the image or provider documentation when the local key, remote path, ownership, and permissions are correct but authentication still fails.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect, back up, and replace keys safely

  • Keep private keys private. Never paste them into a VPS control panel, ticket, chat, repository, or command intended to install a public key.
  • Use one identity per purpose when practical. A named key for a VPS makes revocation and troubleshooting easier than reusing one key everywhere.
  • Do not overwrite blindly. When ssh-keygen reports an existing file, choose a new filename unless you have confirmed that the old key is no longer needed.
  • Preserve the public/private pairing. The .pub file must match the private key you offer. Installing a public key generated from a different private key will always fail.
  • Rotate deliberately. Generate a replacement key, append its public half, test it in a new session, and only then remove the old line from authorized_keys. This avoids locking yourself out.
  • Back up securely. A passphrase-protected private key can be stored in an encrypted backup, but never leave an unprotected copy in cloud-sync folders or shared storage.

Ed25519 versus RSA at a glance

Decision point Ed25519 RSA
Role in this workflow Modern default for current OpenSSH deployments Fallback for legacy or restricted servers
Generation example ssh-keygen -t ed25519 -C "[email protected]" ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_vps
Compatibility Requires server support for Ed25519 Broad legacy compatibility, subject to the server’s RSA signature policy
File handling Private key stays on Mac; matching .pub line goes in authorized_keys Same handling rules; use a distinct filename if another key exists
Choice when VPS version is unknown Try first on a current image; verify provider support Use only when compatibility evidence calls for it

No single algorithm is guaranteed for every VPS. The server’s SSH implementation and provider policy determine what can be accepted.

A repeatable checklist

  • Open Terminal on the Mac.
  • Generate Ed25519, or RSA only for a documented compatibility reason.
  • Accept ~/.ssh/id_ed25519 or choose a new filename without overwriting a needed key.
  • Set a strong passphrase and keep the private file on the Mac.
  • Append only the matching .pub line to the target account’s ~/.ssh/authorized_keys.
  • Set VPS permissions to 700 for ~/.ssh and 600 for authorized_keys; verify ownership.
  • Test with the exact provider-supplied username and address.
  • Use ssh -i and ssh -v when a named key is not automatically offered.
  • Verify the host fingerprint through a trusted provider channel on the first connection.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.