Using SSH keys - Connect to Ionic Pro

Posted on October 03, 2017 in Develop
Updated: June 15, 2021

HowTo connect to Ionic Pro, when ionic link fails?
Ionic Pro is a new site taking over the features from Ionic Cloud - a hosted mobile build, test and deploy service


The problem

I wanted to connect to Ionic Pro from Windows.
But the attempt failed.

It kept coming with one error after the other. The latest I had difficulty to pass was:

>ionic link
× Looking up your apps - failed!
Request: GET
Response: 401
{ type: 'Unauthorized', link: null, message: 'Invalid Token' }

This blog has a workaround for ionic link.

ionic link

ionic link CLI command connects your local git repo with a remote repo at Ionic Pro. That remote repo was created when you manually created an app at Ionic Pro site.

It does that by doing probably all these tasks

  1. creating a set of SSH keys,
  2. uploading the public key to Ionic Pro and
  3. adding the app id to project-root\ionic.config.json
  4. adding remote ionic repo to your local project

So when it won't we can do it ourselves.

The workaround


  • Create a ionic app in Ionic Pro
    After creation the id of the app will be the last part of the url - e.g. as in
  • Create a ionic starter app on your PC

1. Create a set of SSH keys

You need ssh-keygen.exe to generate a set of public/private SSH keys. ssh-keygen.exe is installed as part of

  • Git (default installed into C:\Program Files\Git\usr\bin) or
  • OpenSSH (default installed into C:\Program Files\OpenSSH-Win64)

On my PC I also had HerokuToolkit installed with a path in ssh-keygen.bat to ssh-keygen.exe.
But this path was wrong. It seemed to be part of some problems. Rename that file, so it is not called instead of one of the real .exe files.

From Git bash:


# Generate key-pair into C:\Users\your_userid\.ssh\
cd C:/Users/your_userid/.ssh
ssh-keygen.exe -t rsa -b 4096 -C ""

# Check if ssh agent is running
eval $(ssh-agent -s)
# Agent pid 12345 - yes

# Add private key to agent - 
ssh-add C:/Users/your_userid/.ssh/id_rsa

2. Upload the public key to Ionic Pro

Paste the content of file to a new key in Ionic Pro's SSH store

3. Add the app id to your Ionic config in your local repo

Edit project-root\ionic.config.json

  "name": "Your Magic App",
  "app_id": "09faf85a", # replace with your id

4. Add remote ionic repo to your local project

# Add Ionic Pro as remote repo
git remote add ionic ssh://

After the workaround

5. Upload your app to Ionic Pro

# Upload to Ionic Pro
git push ionic master

6. Make Github your default remote repo

# Add github as remote repo
git remote add origin
# Upload to github and set it default (for pull)
git push --set-upstream origin master
# Check your remotes
git remote -v

7. Continue to use Ionic Pro

On the url for your app - e.g. you can continue to deploy, preview and more.

You might also need to modify src/app/app.module.ts. Define a CloudSettings object.


Download an app as a starter app

If you have access to a Ionic Pro app, you can git clone it with

ionic start --pro-id 09faf85a

... if I am asuming correct.

If you want OpenSSH on Windows

.. then here is how you install OpenSSH

# do this from an admin prompt
choco install openssh # takes a while
# reload environment variables
refresh env

If you want Git Bash to add your Github SSH key to an agent

How to Setup SSH Authentication for Git Bash on Windows

If you want Powershell to add your SSH key to an agent

Setting up the SSH Agent

# PS1
# Make sure you're running as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent
# Add SSH private key to agent
ssh-add c:\users\<yourid>\.ssh\id_rsa
# Verity key added
ssh-add -l


The End