-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git ssh private key binding(GSoC-21) #1111
base: master
Are you sure you want to change the base?
Conversation
The SSHPrivateKey binding will depend on Credential Binding Plugin
Support Git SSH protocol authentication
# Conflicts: # src/main/java/jenkins/plugins/git/GitCredentialBindings.java
Two dependencies are added namely Bouncycastle API Plugin and SSHJ library
This class provides the methods to decrypt a passphrase protected private key in openssh format
Use launcher.isUnix method value to check the current node os environment. Add some formatting
Removing static keyword to support SSHkeyUtils methods
If workspace is provided launcher should not be null
Only supported for linux distro
Return Git SSH environment variables, perform SSH authentication on behalf of the user
Using newly updated getSSHExecutable method
This method provides path to ssh executable
PEMWriter is deprecated
Changing method getSSHCmd signature, ssh exe path papmeter added
… into gitSSHPrivateKey
The passphrase value of a private key is stored as secret rather than in plaintext.
# Conflicts: # pom.xml
# Conflicts: # pom.xml
pom.xml
Outdated
@@ -266,8 +277,8 @@ | |||
<dependencies> | |||
<dependency> | |||
<groupId>io.jenkins.tools.bom</groupId> | |||
<artifactId>bom-2.289.x</artifactId> | |||
<version>987.v4ade2e49fe70</version> | |||
<artifactId>bom-2.263.x</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a bad merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick review, made the changes.
pom.xml
Outdated
<artifactId>bom-2.289.x</artifactId> | ||
<version>987.v4ade2e49fe70</version> | ||
<artifactId>bom-2.263.x</artifactId> | ||
<version>950.v396cb834de1e</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
Not to nag the obvious, but It's Summer 2022, are any "Summer of Code 2022" students going to be assigned to complete this? We could really use this functionality in our Jenkins pipelines managing repos using ssh-keys in .gitmodules. |
No summer of code plan was received that proposed to complete it. You're welcome to test the implementation in your environment based on the build results from the build job on https://ci.jenkins.io/job/Plugins/job/git-plugin/job/PR-1111/ You can also achieve almost the same result for ssh private keys by using the |
FYI, the I found the ssh-agent plugin by itself doesn't configure github host public-ssh-key in the known_hosts and will cause the git commands to hang until configured in there. For reference for others, I got it working with:
(note this was IBM's internal github, but same concept with whatever the github url is). |
} | ||
|
||
@RequirePOST | ||
public ListBoxModel doFillGitToolNameItems() { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check
|
||
public class OpenSSHKeyFormatImpl { | ||
|
||
private final String privateKey; |
Check warning
Code scanning / Jenkins Security Scan
Jenkins: Plaintext password storage
JENKINS-28335 - Add Git Credentials binding for SSH Private Key
The
gitSshPrivateKey
implementation provides git authentication support over SSH protocolusing private key and passphrase credentials of a user. The binding uses two git specific environment
variables depending upon the minimum CLI-git version
GIT_SSH_COMMAND
- If version is greater than 2.3, then the GIT_SSH_COMMAND environment variable provides ssh command including the necessary options which are: path to the private key and host key checking to authenticate and connect git server without using an executable script.SSH_ASKPASS
- If version is less than 2.3, an executable script is attached to the variable which provides ssh command including the necessary options which are: path to the private key and host key checking to authenticate and connect git servePlease refer to the Project page for more details-
https://www.jenkins.io/projects/gsoc/2021/projects/git-credentials-binding/
Checklist
Types of changes