Jenkins: what is the correct format for private key in Credentials

前端 未结 6 1726
难免孤独
难免孤独 2020-11-22 07:16

I\'m creating a job in Jenkins 2.152 running on Windows Server 2016 which needs to pull from a git repo hosted on bitbucket.org. I tested the ssh key through git-bash so I k

6条回答
  •  抹茶落季
    2020-11-22 07:51

    following worked for me

    1. Create a folder (say testkey), cd inside the folder and right click and select git bash

    2. now create OPENSSH Key using following command in git bash. here test.key is name of your OPENSSH key (note that passphrase is optional)

    ssh-keygen -f test.key

    1. Copy that key connect, you can open the key using notepad, and paste that key into github. Remember Git accepts only OPENSSH key.

    1. Now convert that key into PEM format, using same bash window, run following command (note that passphrase is optional)

    ssh-keygen -f test-pem.key -m PEM -p

    1. Now the key is converted into PEM key, copy the content of the key using notepad.

    2. Go Jenkins -> Credentials -> Add New Credentials.

    7.Select Kind SSH Username and Key , Provide username , and paste the PEM key content copied in step 5 and paste into private key, note that passphrase is optional.

    1. Now add repo for ssh like this,

    Original SSL Command Copied from GITHUB - git@github.com:test/goto.git

    change it to  - ssh://git@github.com/test/goto.git
    

提交回复
热议问题