How to Transfer SSH Keys to a New Mac

Securely migrate your existing SSH keys to a new Mac using the command line and secure file transfer protocols. Step-by-step instructions.

  1. Locate the SSH directory on the source Mac. Open the Terminal on your current Mac. Navigate to the hidden SSH directory by entering the command: cd ~/.ssh. Verify the presence of your key files, typically named id_rsa or id_ed25519, by typing ls -la.
  2. Copy the SSH keys to an external drive. Copy the entire .ssh folder contents to an external USB drive or use a secure cloud storage solution. Ensure you include both the public (.pub) and private key files. If using a thumb drive, use the cp command: cp -r ~/.ssh /Volumes/YourDriveName.
  3. Create the SSH directory on the new Mac. On your new Mac, open Terminal. Create the necessary hidden directory by entering: mkdir -p ~/.ssh. Set the correct permissions to ensure security by running: chmod 700 ~/.ssh.
  4. Move the keys to the new home folder. Copy the contents from your external source into the new ~/.ssh directory. Once moved, set the file permissions for the private keys to 600 using: chmod 600 ~/.ssh/id_rsa (replace with your specific filename).
  5. Add the private key to the SSH agent. Register your key with the macOS SSH agent to enable automatic passphrase handling. Run: ssh-add --apple-use-keychain ~/.ssh/id_rsa. This command stores your passphrase in the macOS Keychain so you do not need to re-enter it frequently.
  6. Verify the connection. Test the connection to a known remote host by running: ssh -T [email protected] (or your specific server). If configured correctly, the terminal will confirm successful authentication without prompting for a password.

Related

  • How to Create Room Groups for Lights and Speakers
  • How to link streaming music services to your smart speaker
  • How to Configure Multi-Room Audio with Smart Speakers
  • How to Safely Set Up and Configure Smart Plugs
  • How to Install a Smart Light Switch
  • Maintaining Power Continuity for Smart Light Bulbs