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 in Account settings, under SSH keys and tokens (HTTPS tokens when Magpie does not accept SSH). A button with the same name is at the top of Git Repositories and opens that page in a new tab.
A token or key belongs to your account, not to a team. It can do what your account can do and no more. When you make it, you can also limit it to read only, and to one team's repositories or to repositories you choose. The section Limit what a key or token can reach below describes the choices.
Anyone can clone a public repository over HTTPS without a token.
Clone or push over HTTPS
- In Account settings, open SSH keys and tokens (or HTTPS tokens) and select Create token.
- Give it a name, such as the computer it will be used on.
- Choose Read only to clone and pull, or Read and write to push as well.
- Choose which repositories it can reach.
- Select Create token. Copy the token straight away: it is shown only on the page that opens, 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, unless you have copied something else or left the page since. 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. - In Account settings, open SSH keys and tokens and select Add SSH
key. Paste the key. Paste only the contents of the
.pubfile, on one line; the form refuses a private key. - Choose Read only or Read and write, and which repositories the key can reach.
- Select Add SSH 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 what it can do, which repositories
it reaches, 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.
Limit what a key or token can reach
A key or token never gives more access than your account has. The limits narrow it, and are chosen when it is made.
Access
- Read only clones and pulls. It cannot push.
- Read and write clones, pulls and pushes, where your account may push.
Repositories it can reach
- Every repository I can use reaches Personal and every team you belong to, including repositories added later.
- One team reaches the repositories of the team you choose, including repositories added later.
- Only repositories I choose reaches the repositories you tick, up to 50. Repositories added later are not included.
For example, a token for a build server can be Read only and reach one repository. If the token is copied, it can read that repository and nothing else.
The limits cannot be changed afterwards. To change them, revoke the token, or remove the key and add it again. A key or token made before limits existed can push and reaches every repository.
In the Magpie app
In the app, open Git repositories, then SSH keys and tokens (or HTTPS tokens when Magpie does not accept SSH) from its menu. The page lists the same SSH keys and tokens as the website, with what each can do and reach.
- To add a key, tap the + button, choose Add SSH key, paste the public key and tap Add. A private key is refused. A key or token made in the app can push where your account can, and reaches every repository you can use.
- Tap a key to rename it. Tap the check command to copy it, then run it on the computer.
- To remove a key or revoke a token, swipe its row, or hold it, and confirm.
- Create an HTTPS token shows the new token once. Reveal it or share it to somewhere private, such as a password manager.
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, its access, which repositories it reaches and the first characters of the token; 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 only is enough to clone a private repository, and Read and write is needed to push. Create a new token if you no longer have it. |
| The requested URL returned error: 429 | Git sent 20 tokens that did not work from your address within an hour, so Magpie is waiting before it checks another. Wait the few minutes Git reports, then try again with an active token. A token that works ends the wait for your address. |
| 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. |
| This token is limited to other repositories | Over HTTPS, your account can read the repository, and the token was made without it. Use another token, or create one that reaches 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. |
| This SSH key is limited to other repositories | Your account can read the repository, and the key was added without it. Add a key that reaches it. |
| This SSH key is read only, so it cannot push | The key was added as Read only. Remove it and add it again as Read and write. |
| … has no room for more code | The storage of the repository's place, Personal or its team, is full. A repository counts its size on disk with every other file in the place. Delete files you no longer need, or move to a plan with more storage, then push again; see Plans, limits, and billing. Deleting a branch is always allowed. |
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 token reaches every repository you can use. 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.