Franchise
Franchise

Reputation: 1241

How to create Jenkins SSH key in Linux for use with Github?

At the moment, I'm trying to configure an SSH key to use for cloning Github repositories into a Jenkins pipeline. When I login to my Linux server as the Jenkins user and attempt to create a SSH keypair, below is the output I get:

-bash-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/jenkins/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "/var/lib/jenkins/.ssh/id_rsa" failed: Permission denied

Do I need to elevate my privileges in order to create these keys? Thanks.

Upvotes: 0

Views: 1717

Answers (1)

Franchise
Franchise

Reputation: 1241

Figured it out. When running the ssh-keygen command, it likes to create the .ssh directory on its own. I had created it ahead of time and that clearly created some sort of permissions issue.

So in the future: if you're ever creating these keys and getting a permissions error, allow the command to create the .ssh directory to avoid any issues. Thanks.

Upvotes: 2

Related Questions