Home/Guides/How to set up git and an SSH key for GitHub on a remote Mac mini

How to set up git and an SSH key for GitHub on a remote Mac mini

Updated · airankrush

What this guide covers

When you finish, this machine can pull and push your repositories over SSH, and you can revoke this one key at any time. You need: a GitHub account and access to the browser inside the remote desktop.

Steps

  1. Set your commit identity first

    The command line tools include git, so it is enough that git --version prints something. Then set the commit identity for this machine: git config --global user.name "Your Name" and git config --global user.email "your email". The email has to match one registered on your GitHub account for commits to be attributed to you.

  2. Generate a new key on this machine

    Do not copy the private key from your own computer over the remote clipboard or file transfer: that key usually opens your other servers as well. Use one key per machine, so that if it is lost or the rental ends you revoke only that one. Following the official GitHub docs:

    ssh-keygen -t ed25519 -C "Contact support"

    We suggest setting a passphrase when prompted. You can change the comment to something that identifies this machine, which makes the key easier to tell apart on GitHub later.

  3. Have the keychain remember the passphrase

    The official docs start with eval "$(ssh-agent -s)" and then put this in ~/.ssh/config:

    Host github.com
      AddKeysToAgent yes
      UseKeychain yes
      IdentityFile ~/.ssh/id_ed25519

    Then run ssh-add --apple-use-keychain ~/.ssh/id_ed25519. If you set no passphrase, the docs say to remove the UseKeychain line and leave out --apple-use-keychain.

  4. Add the public key to your GitHub account

    pbcopy < ~/.ssh/id_ed25519.pub copies the public key to the remote Mac's clipboard. Then log in to GitHub in the browser inside the remote desktop, go to Settings → SSH and GPG keys → New SSH key, and paste it. The whole process happens on the remote Mac, so the public key never has to pass through your local computer. Give it a title that says which machine it is and the date you added it.

  5. Test the connection

    Run ssh -T Contact support. The first time, you are asked to confirm the host fingerprint; check it and type yes. When you see You've successfully authenticated, but GitHub does not provide shell access. with your username in it, the connection works. See the official testing instructions.

  6. Narrow the access if you only need a few repositories

    An SSH key added to your account can reach every repository under that account. If this machine only runs one or two projects, consider a GitHub deploy key (valid for a single repository) or a fine-grained access token. Follow the official GitHub docs for the details. This is especially worth doing on a machine where an agent commits code automatically.

  7. Revoke and delete before the rental ends

    The machine is reclaimed and reinstalled after the rental ends, but do not rely on the reinstall for your security. Before handing it back: delete this public key on GitHub's SSH and GPG keys page, delete the matching private key file from ~/.ssh on the machine, and confirm that all local commits have been pushed.

FAQ

After a restart, the first git operation asks for the passphrase or fails. Why?

The keychain unlocks only after you log in to the desktop. After a restart, log in to the system once through the remote desktop, then run git. A background job that starts before login runs into the same thing.

Can I use HTTPS with a token instead?

Yes, GitHub supports that as well. The same advice applies: create a token for this machine only, give it the minimum permissions, set an expiry, and revoke it on GitHub when the rental ends.

Can the platform see my code or my private key?

The platform runs the necessary operational and security monitoring (such as processes, network connections and configuration state). It does not record the screen or the content of your business data, and it does not proactively access what is on the device. See this explanation. For confidential projects, check your own organization's requirements first.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All guides