Clone and push with a token or SSH key
Connect Git on your computer to a Magpie repository with an HTTPS token or an SSH key, then clone, pull and push.
Git connects to a Magpie repository over HTTPS, with a token as the password, or over SSH, with a key from your computer. Both are managed on the page linked from the top of Git Repositories: Get an HTTPS token, or SSH keys and tokens when Magpie accepts SSH. A token or key belongs to your account and works for every repository your account can read or push to.
Anyone can clone a public repository over HTTPS without a token.
Clone or push over HTTPS
- Open Get an HTTPS token (or SSH keys and tokens) and open Create token.
- Give it a name, such as the computer it will be used on. Tick Read repositories to clone and pull, and Write to repositories to push. Tick both to do both.
- Select Create token. Copy the token straight away: it is shown only on this page, once.
- Copy the clone address from the repository's page, such as
https://magpie.diy/g/team/repository.git, and rungit clonewith it. - When Git asks for a username and password, enter any username and paste the token as the password. Do not use your Magpie password, and do not put the token in the address.
A Git credential helper, such as Keychain on a Mac, can store the token so Git does not ask again.
A repository nothing has been pushed to yet shows the commands to start a
project or to push one you already have. Each command uses the repository's
address and default branch. Cloning creates the origin remote, so in a clone
push with git push; do not add origin a second time.
The new token is hidden on screen. Copy token copies it without showing it; the clipboard is cleared 30 seconds later. Reveal shows it; leaving the tab or pressing Escape hides it again. If you have a Password Vault, Save in Password Vault opens it in a new tab with the token ready to save. Unlock Password Vault and save the item. The token goes from one tab to the other in the browser and is not sent to Magpie again.
Clone or push over SSH
When Magpie accepts SSH, the page is called SSH keys and tokens and has an SSH keys list. Add a public key from your computer once; Git then connects without asking for a username or password.
- In Terminal, run
ls ~/.ssh/id_ed25519.pub. If the file does not exist, create a key withssh-keygen -t ed25519and press Return to accept the default file. - Copy the public key. On a Mac,
pbcopy < ~/.ssh/id_ed25519.pubcopies it. - Open Add SSH key, paste the key, and select Add SSH key. Paste only
the contents of the
.pubfile, on one line; the form refuses a private key. - Run the check command shown under SSH keys, such as
ssh -T git@magpie.diy. It replies with the Magpie account the key belongs to.
Once your account has a key, a repository's page shows Clone over SSH with
an address such as git@magpie.diy:team/repository.git, and its commands use
that address. To switch a clone made with the HTTPS address, run the
git remote set-url origin … command under Switch a clone from HTTPS to
SSH on the repository's page.
The key's comment, usually your user and computer name, becomes its name.
Click the name to change it. Each key shows its SHA256 fingerprint, which
matches ssh-keygen -lf ~/.ssh/id_ed25519.pub, and the date Git last used it.
A key can be on only one Magpie account; for a second account, create a second
key. SSH can only clone, fetch and push: it gives no shell.
If the page is called Get an HTTPS token and has no SSH keys, SSH is not available and Git connects over HTTPS.
Revoke a token or remove a key
Select Revoke beside a token, or Remove beside a key, and confirm. Git connections that use it stop working. The list shows each active token's name, the first characters of the token and its Git access; those characters cannot be used as the token.
When Git refuses
| Git says | What it means |
|---|---|
| Authentication failed | Over HTTPS, the password was not an active token with the access needed: Read repositories to clone a private repository, Write to repositories to push. Create a new token if you no longer have it. |
| The requested URL returned error: 403 | The token was accepted, but your account cannot read this repository, or can read it but not push to it. |
| Repository … not found, over HTTPS | The address is wrong. Copy it again from the repository's page. |
| Permission denied (publickey) | The SSH key is not on a Magpie account, or SSH is offering a different key. Run the check command shown under SSH keys. |
| Repository not found, over SSH | The address is wrong, or your account cannot read the repository. |
| Your Magpie account can read this repository but cannot push to it | Your account has read access only. |
A token or key gives no access by itself: your account needs access through the repository's team or as a collaborator, as described in Git Repositories.
In the Magpie app
In the native app, choose HTTPS tokens from the menu on Git repositories to see your active tokens, revoke one, or tap New to create one. Pick Read only, Read and write or Write only. The new token is hidden until you tap Reveal token, and is shown only on that screen: tap Share token to send it somewhere private, such as a password manager, before tapping Done. SSH keys cannot be added in the app.
For Git access that does not match the page, Contact support.
Ask Magpie support
Send Magpie staff a question about anything this article does not answer.