Unable to ssh into my Jenkins docker instance

30 views
Skip to first unread message

Parichay Barpanda

unread,
Mar 23, 2019, 9:37:34 PM3/23/19
to Jenkins Developers
Hi all,

I am trying to use Jenkins Remote CLI to configure my Jenkins server remotely. I am running a jenkinsci/blueocean docker container. 

To enabled SSHD on my jenkins server:
1) At http://localhost:8080/configureSecurity/ : Enabled SSHD Port -> Random
2) AT http://localhost:8080/user/baymac/configure: Added my Public key of local machine

Trying ssh from bash:
ssh -l baymac -p 46653 localhost who-am-i

Error message:
ssh: connect to host localhost port 46653: Connection refused

Trying to use Jenkins CLI client to ssh into Jenkins server with the following command:

java -jar jenkins-cli.jar -s http://localhost:8080 -i ~/.ssh/id_rsa -ssh -user baymac who-am-i

I receive an error message:
Enter passphrase for /home/parichay/.ssh/id_rsa:
Mar 24, 2019 6:38:56 AM org.apache.sshd.client.config.hosts.ConfigFileHostEntryResolver reloadHostConfigEntries
INFO: resolveEffectiveResolver(baymac@localhost:46653) loaded 1 entries from /home/parichay/.ssh/config
org.apache.sshd.common.RuntimeSshException: Failed to get the session.
at org.apache.sshd.client.future.DefaultConnectFuture.getSession(DefaultConnectFuture.java:59)
at hudson.cli.SSHCLI.sshConnection(SSHCLI.java:104)
at hudson.cli.CLI._main(CLI.java:608)
at hudson.cli.CLI.main(CLI.java:427)
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishConnect(UnixAsynchronousSocketChannelImpl.java:252)
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:198)
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:293)
at java.lang.Thread.run(Thread.java:748)

I enter the right passphrase, since I tried to ssh into another device it is working.

Extra information:

I run the docker with the following command:

sudo docker run \ 

  --rm \ 

  -u root \ 

  -p 8080:8080 \ 

  -v jenkins-data:/var/jenkins_home \ 

  -v /var/run/docker.sock:/var/run/docker.sock \ 

  -v "$HOME":/home \ 

  --name jenkins \ 

  Jenkinsci/blueocean 


HTTP auth works:
java -jar jenkins-cli.jar -s http://localhost:8080/ -auth baymac:<api_token> who-am-i

Message: 
Authenticated as: baymac
Authorities:
  authenticated

I am unable to debug this, a pointer to this error would be really helpful.

Regards,
Parichay (baymac)

Mark Waite

unread,
Mar 24, 2019, 7:21:28 PM3/24/19
to jenkinsci-dev
This is really a question for the Jenkins users list, not for the developers list.  The developers list is used for discussions related to developing capabilities for Jenkins, not for those using Jenkins to do their own development.

In your specific case, the docker run command needs to have a command line argument that will allow ssh traffic through to the Jenkins port that is listening for ssh.  Just as it has a port 8080 command line argument, it needs another argument that will allow ssh traffic to reach Jenkins.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/53f15502-cf94-4a51-9202-7f0080e45c05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Parichay Barpanda

unread,
Mar 25, 2019, 5:51:02 AM3/25/19
to jenkin...@googlegroups.com
I got a bit confused which mailing list to choose while posting this thread. Now I understand the difference. Thank you for the clarification.

Regards,
Parichay (baymac)




Reply all
Reply to author
Forward
0 new messages