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

前端 未结 6 1800
难免孤独
难免孤独 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 08:04

    So just to add an answer to actually convert a key from the new OPENSSH format to the older PEM format:

    $ ssh-keygen -f blah.key
    Generating public/private rsa key pair.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in blah.key.
    Your public key has been saved in blah.key.pub.
    The key fingerprint is:
    SHA256:ndMFvZjbD7M3MoqFy8+me74gPhcuoDVLF2/Oh+hXQ8I perbelding@erpelbook4.local
    $ head -n 1 blah.key
    -----BEGIN OPENSSH PRIVATE KEY-----
    $ ssh-keygen  -f blah.key -m PEM -p
    Key has comment 'redacted'
    Enter new passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved with the new passphrase.
    $ head -n 1 blah.key
    -----BEGIN RSA PRIVATE KEY-----
    

    ssh-keygen -p changes the passphrase but it does not mind the new passphrase being the same (even none) as the old one and in the process can convert the format.

提交回复
热议问题