How do I use an ssh-rsa key with Azure DevOps in Codemagic?
Last updated: June 26, 2026
Context
Azure DevOps may require ssh-rsa keys for repository access, while Codemagic generates SSH keys using the ed25519 algorithm by default. If your Azure DevOps project only accepts RSA keys, you can add your own ssh-rsa key to Codemagic and use it for cloning and fetching.
Answer
Follow these steps to generate an ssh-rsa key and configure it for use with Azure DevOps in Codemagic.
Generate a 4096-bit RSA key on your machine:
ssh-keygen -t rsa -b 4096 -C "codemagic@yourdomain.com"This creates a private key (for example, id_rsa) and a public key (id_rsa.pub).
Add the private key to Codemagic as a secure environment variable:
Copy the entire contents of your private key file.
In Codemagic, create a new Environment variable and paste the private key value. Name the variable so it ends with
_SSH_KEY(for example,AZDO_SSH_KEY) and mark it as secure/hidden.
YAML users: Import and reference this variable in your
codemagic.yamlso Codemagic can use it during the checkout.Add the public key to Azure DevOps:
Copy the contents of your
.pubfile.In Azure DevOps, go to User settings → SSH Public Keys → Add, then paste the public key.
Use the SSH repository URL:
Ensure your repository URL is the SSH form, for example:
git@ssh.dev.azure.com:v3/<org>/<project>/<repo>.
Notes:
Codemagic recognizes environment variables whose names end with
_SSH_KEYas SSH private keys.If you’re using the Workflow Editor (not YAML), you can still add the private key as a secure Environment variable ending with
_SSH_KEYand use the SSH repository URL.There is currently no automatic conversion from Workflow Editor to YAML; you’ll need to set up a YAML workflow manually if you wish to migrate.
Sources:
Codemagic YAML quick start: https://docs.codemagic.io/yaml-quick-start/building-a-flutter-app/
Azure DevOps: Manage SSH public keys: https://learn.microsoft.com/azure/devops/repos/git/use-ssh-keys