You've successfully subscribed to Nicholas Workshop
Great! Next, complete checkout for full access to Nicholas Workshop
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

SSH into Your CircleCI Server

Nicholas Wong
Nicholas Wong

1. Generate a set of SSH key pair in your server

You would need a public and private of SSH key, theoretically it can be generated in any computer as you like. The following is a sample to generate the key.

ssh-keygen -t rsa -b 4096 -C ""

2. Add your public key as an authorized key in your server

If your key is generated in the  server side, run the following key to

cat ~/.ssh/ > ~/.ssh/authorized_keys

3. Add your private key into CircleCI

Copy the content of your private key, open your circleCI project, go to `Setting > SSH Permission`, add new. Paste your key.

4. Inject SSH fingerprint into your config script

After step 3 you will see the fingerprint of your key in the page. Copy it and use it in the following script. Also add a script to make your server a known host.

- add_ssh_keys:
    - "a2:e5:14:ca:27:8b:f2:fc:b1:ed:80:0c:68:04:a4:8a"
- run:
    name: Make remote server a known host
    command: ssh-keyscan username@hostname >> ~/.ssh/known_hosts

5. After that you can SSH to your server.

ssh username@hostname 'mkdir -p /home/shared/artifacts'


Nicholas Wong

Fullstack software engineer with strong background in computer science and extensive experience in software engineering and architecture. Studied in NYU, worked in Yahoo, Rakuten and Manulife.