-   Linux - Server (
-   -   Jenkins in docker ssh issue (

grzeslaw 08-29-2019 12:06 PM

Jenkins in docker ssh issue

I'm using MacOS.
Today I created docker container with Jenkins for pipeline testing purpose.
To make it working, I need ssh key access from jenkins container to my MacOS shell.
I simply go to container, generate ssh key, copy it to my Mac, and that should work.
Sadly it constantly asking me for password, even PubkeyAuthentication is enabled.

Any ideas what might be wrong?


mum@bb-l-m-gd-200 ~/projects/repo$ docker exec -ti jenkins /bin/bash
jenkins@46e0509ddfae:/$ hostname
jenkins@46e0509ddfae:/$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/var/jenkins_home/.ssh/id_rsa):
Created directory '/var/jenkins_home/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/jenkins_home/.ssh/id_rsa.
Your public key has been saved in /var/jenkins_home/.ssh/
The key fingerprint is:
SHA256:CwsvRfnMie4wfj2b/o705+XJrPpVykY39l/3CcLBn3g jenkins@46e0509ddfae
The key's randomart image is:
+---[RSA 2048]----+
|                |
|      .        |
|      o          |
|    . = ..      |
|    . + S  o  .oo|
|    = o .. +oo+o|
|    + +.o  + E* +|
|  . =..o+  +B..*|
|    ....====+.=.o|
jenkins@46e0509ddfae:/$ ssh-copy-id
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/jenkins_home/.ssh/"
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:1ZZ+BrXKS7IGTYM+De6Fulq1LK3CIMRhxZmhmB+WrWE.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Number of key(s) added: 1

Now try logging into the machine, with:  "ssh ''"
and check to make sure that only the key(s) you wanted were added.

jenkins@46e0509ddfae:/$ ssh
Last login: Thu Aug 29 18:46:15 2019 from
bb-l-m-gd-200:~ jenkins$
bb-l-m-gd-200:~ jenkins$ hostname
bb-l-m-gd-200:~ jenkins$
bb-l-m-gd-200:~ jenkins$ cat /private/etc/ssh/sshd_config|grep  PubkeyAuthentication
PubkeyAuthentication yes
bb-l-m-gd-200:~ jenkins$
bb-l-m-gd-200:~ jenkins$ ls -l ~/.ssh/authorized_keys
-rw-------  1 jenkins  staff  804 Aug 29 18:48 /Users/gdajuk/projects/repo/.ssh/authorized_keys
bb-l-m-gd-200:~ jenkins$
bb-l-m-gd-200:~ jenkins$ logout
Connection to closed.
jenkins@46e0509ddfae:/$ exit
mum@bb-l-m-gd-200 ~/projects/repo$

grzeslaw 08-30-2019 02:09 AM

The host is fresh, so there are no more keys there.
Even I provide the key from the CLI after ssh, it doesn't help..

All times are GMT -5. The time now is 01:39 AM.