[JENKINS-36997] CLI implementation of RemoteAgent#18
[JENKINS-36997] CLI implementation of RemoteAgent#18jglick merged 20 commits intojenkinsci:masterfrom
Conversation
…stalled on a slave. Not working yet with keys protected by a passphrase.
OpenSSH 7.0 and greater disables use of ssh-dss public key algorithm. To allow tests to run on system with OpenSSH 7.0, explicitly enable ssh-dss by passing `-o HostKeyAlgorithms=+ssh-dss`.
Older OpenSSH implementations does not support the `...=+ssh-dss` syntax to add a key alg (mind the `+`), So use `...=ssh-dss` to make tests working also on pre-7.0 versions of OpenSSH. This is an amendment of commit 66bae3b.
…AgentServer would create.
Switching expectation to what ssh-agent, via ExecRemoteAgent, will create. From the man page:
FILES
$TMPDIR/ssh-XXXXXXXXXX/agent.<ppid>
UNIX-domain sockets used to contain the connection to the authen‐
tication agent. These sockets should only be readable by the
owner. The sockets should get automatically removed when the
agent exits.
…ree to connect to the test server without special options. apache/mina-sshd#29
…emoting calls were not exercised.
| tw.writeMPInt(rpk.getModulus()); | ||
| return new String(Base64.encode(tw.getBytes())); | ||
| } | ||
| if (pk instanceof DSAPublicKey) { |
There was a problem hiding this comment.
Our tests use RSA, so there is no need to even check for this.
| sshd.getProperties().put(SshServer.WELCOME_BANNER, "Welcome to the Mock SSH Server\n"); | ||
| sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(hostKey.getPath()))); | ||
| SimpleGeneratorHostKeyProvider hostKeyProvider = new SimpleGeneratorHostKeyProvider(new File(hostKey.getPath())); | ||
| hostKeyProvider.setAlgorithm(/* TODO when upgrading sshd: KeyUtils.RSA_ALGORITHM */"RSA"); // http://stackoverflow.com/a/33692432/12916 |
There was a problem hiding this comment.
Allow tests to run even with a newer ssh command connecting.
| job.getBuildersList().add(shell); | ||
|
|
||
| r.assertLogContains("Permission denied (publickey).", r.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get())); | ||
| r.assertLogContains("Failed to run ssh-add", r.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get())); |
There was a problem hiding this comment.
Used to proceed with the block even when the passphrase was bad, which did not make much sense—better to fail at once.
| * Stops the agent. | ||
| */ | ||
| void stop(); | ||
| void stop() throws IOException, InterruptedException; |
There was a problem hiding this comment.
These methods may now be running remote commands, so they should be allowed to throw reasonable exceptions.
| } finally { | ||
| purgeSockets(); | ||
| } | ||
| purgeSockets(); |
There was a problem hiding this comment.
Various updates related to exception handling from stop.
| SystemCredentialsProvider.getInstance().save(); | ||
|
|
||
| FreeStyleProject job = r.createFreeStyleProject(); | ||
| job.setAssignedNode(r.createSlave()); |
There was a problem hiding this comment.
Make sure the remote part works.
| story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)); | ||
|
|
||
| Pattern pattern = Pattern.compile("(?:SSH Agent (?:before|after) restart )/.+/ssh([0-9])+"); | ||
| Pattern pattern = Pattern.compile("(?:SSH Agent (?:before|after) restart )/.+/ssh-.+/agent.(\\d)+"); |
There was a problem hiding this comment.
Different socket path name patterns created by new implementation.
| <jenkins.version>1.609.3</jenkins.version> | ||
| <java.level>7</java.level> <!-- sshd-core is 7+ --> | ||
| <workflow-jenkins-plugin.version>1.9</workflow-jenkins-plugin.version> | ||
| <workflow-jenkins-plugin.version>1.14.2</workflow-jenkins-plugin.version> |
There was a problem hiding this comment.
The latest compatible with 1.609.3.
|
@reviewbybees done |
JENKINS-36997; trying to finish #17.
-o HostKeyAlgorithms=ssh-dss(reference)ExecRemoteAgent.agent@reviewbybees