Skip to content

gitlab-ci.yml: scp: Permission denied (publickey)

L'authentification de la commande scp échoue alors qu'elle réussit en local. CI_SSH_KEY a bien été renseigné.

junit:
    image: maven:3.6.1-jdk-11
    before_script:
        - . summeet/setup-mvn-proxy.sh
    script:
        - cd summeet && mvn test && mvn -X checkstyle:check
deploy:
    image: maven:3.6.1-jdk-11
    before_script:
        - . summeet/setup-mvn-proxy.sh && chmod 400 $CI_SSH_KEY
    script:
        - pwd
        - ls -l
        - scp -v -o StrictHostKeyChecking=no -i $CI_SSH_KEY README.md gitlabci@192.168.74.202:/tmp
Running with gitlab-runner 13.3.1 (738bbe5a)
  on forge-runner-2-docker ubuPbLJk
Preparing the "docker" executor
00:06
Using Docker executor with image maven:3.6.1-jdk-11 ...
Pulling docker image maven:3.6.1-jdk-11 ...
Using docker image sha256:d9d0b7c97e99e8dab881c114ef55b9cc4dfcd944c258924c080eac5099403d89 for maven:3.6.1-jdk-11 ...
Preparing environment
00:01
Running on runner-ubupbljk-project-15760-concurrent-0 via forge-runner-2...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/p1712760/summeet/.git/
Checking out 908ecc98 as master...
Removing summeet/target/
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ . summeet/setup-mvn-proxy.sh && chmod 400 $CI_SSH_KEY
$ pwd
/builds/p1712760/summeet
$ ls -l
total 8
-rw-rw-rw- 1 root root  935 Oct 21 09:39 README.md
drwxrwxrwx 3 root root 4096 Oct 21 11:22 summeet
$ scp -v -o StrictHostKeyChecking=no -i $CI_SSH_KEY README.md gitlabci@192.168.74.202:/tmp
Executing: program /usr/bin/ssh host 192.168.74.202, user gitlabci, command scp -v -t /tmp
OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2s  28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.74.202 [192.168.74.202] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: SELinux support disabled
debug1: key_load_public: No such file or directory
debug1: identity file /builds/p1712760/summeet.tmp/CI_SSH_KEY type -1
debug1: key_load_public: No such file or directory
debug1: identity file /builds/p1712760/summeet.tmp/CI_SSH_KEY-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u6
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.74.202:22 as 'gitlabci'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:nbeBfkVvEt7XQ/FjJHTIzoTs70+RxTMNFKT33jwEe5Y
Warning: Permanently added '192.168.74.202' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /builds/p1712760/summeet.tmp/CI_SSH_KEY
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: No more authentication methods to try.
Permission denied (publickey).
lost connection
ERROR: Job failed: exit code 1