0

I want to set up a Linux node as a slave to the Jenkins master. I was going through the tutorial on setting it up for a Linux machine.

Have master launch slave agent via SSH

Jenkins has a built-in SSH client implementation that it can use to talk to remote sshd and start a slave agent. This is the most convenient and preferred method for Unix slaves, which normally has sshd out-of-the-box. Click Manage Jenkins, then Manage Nodes, then click "New Node." In this set up, you'll supply the connection information (the slave host name, user name, and ssh credential). Note that the slave will need the master's public ssh key copied to ~/.ssh/authorized_keys.

When it says ~/.ssh/authorized_keys does it mean that I need to have the public key in this location on the node when logged in as a jenkins user (which is the username that the Master uses to log into the slaves)?

What does ~ signify? Which user's home directory are we talking about?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Müller
  • 973
  • 6
  • 19
  • 38

2 Answers2

2

To be precise,

  • the public key to be copied is the public key of the user running the master
  • the destination is the .ssh/authorized_keys file of the user on the slave (ie, the user whose credentials you select for the ssh connection on the Jenkins node config page).

The ~ character is expanded by most shells to the current user's home directory (e.g., /home/userxyz).

Alex O
  • 7,746
  • 2
  • 25
  • 38
1

~ means the user that is running Jenkins.

And yes, ~/.ssh/authorized_keys means authorized_keys for the Jenkins user (the one running on your Jenkins server, not literally jenkins).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
  • Thanks! I am still confused. I have a user named `jenkins` with a private key configured in the `Manage Credentials` area. So it is the corresponding public key that needs to go into `/home/jenkins/.ssh/authorized_keys` of the slave node. Am i correct? Also, is there some flexibility to this location - can i have it at `/data/jenkins/.ssh/authorized_keys` (some place common to more than one user trying to access the node)? – Müller Jul 28 '16 at 06:24
  • You can also paste your slave machines private key directly by using "Enter directly" option under "SSH Username with password" – mahinlma Jul 28 '16 at 13:38
  • I think this answer could benefit from a clearer explanation. – Peter Mortensen Aug 11 '18 at 09:51