Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add SSH Key in Travis CI?

In Travis Doc there is tab "SSH Key" in Settings, but not in my account. I need to add SSH Key to clone submodules on GitHub.

My Account:

enter image description here

Travis Doc:

enter image description here

like image 648
acfreitas Avatar asked Dec 12 '14 13:12

acfreitas


2 Answers

Using SSH keys is only available for private repositories on travis-ci.com (paid plans).

With the travis command line tool you can generate a new SSH key which will be set up on both Travis CI and your GitHub user account (if you use a dedicated GitHub user for Travis CI).

Here are the necessary console commands:

# Install Travis command line tool
gem install travis

# Login to Travis Pro (private repositories) account
travis login --pro

# Generate and setup SSH key for your GitHub repository
travis sshkey --generate -r organization/repository

Instead of generating a new SSH key with travis, it's also possible to upload an existing SSH key with:

travis sshkey --upload "C:\my_keys\id_rsa" -r organization/repository

Once the SSH key has been created, it is recommended that this key will be refrenced from the config file in the .ssh directory of your Travis user. You can do this by adding these lines to your .travis.yml:

# http://docs.travis-ci.com/user/build-lifecycle/
before_script:  
  - echo -e "Host github.com\n\tHostName github.com\n\tUser git\n\tIdentityFile ~/.ssh/id_rsa\n" >> ~/.ssh/config

For more information, here is a link to the official documentation: Generating a new key.

like image 95
Benny Neugebauer Avatar answered Sep 21 '22 03:09

Benny Neugebauer


This feature is only available for private repositories currently.

For public repositories, you shouldn't need them to be private Git URLs (assuming they're on GitHub), so changing the URLs to use public clone URLs should do the trick.

like image 32
roidrage Avatar answered Sep 19 '22 03:09

roidrage