我是gitlab的新手,希望能在这里找到帮助。
我在gcp中有一个运行debian linux的vm。
我正在使用gitlab将更改推送到该vm。
对于先决条件,我生成了ssh密钥并将其添加到gitlab中。
这就是我的gitlab-ci.yml的样子

before_script:
 - apt-get update -qq && apt-get install -y -qq sshpass

deploy_stage:
  stage: deploy
  environment: Staging
  only:
    - stage
  script:
    - ls
    - sshpass -V
    - export SSHPASS=$USER_PASS
    - sshpass -e scp -o stricthostkeychecking=no -r . [email protected]:/datastore/test

但是当我合并一个更改时,我得到以下错误
管道作业的输出
$ ls
test
test2
test2-merge
$ sshpass -V
sshpass 1.06
(C) 2006-2011 Lingnu Open Source Consulting Ltd.
(C) 2015-2016 Shachar Shemesh
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information.

Using "assword" as the default password prompt indicator.
$ export SSHPASS=$USER_PASS
$ sshpass -e scp -o stricthostkeychecking=no -r . [email protected]:/datastore/test
***Warning: Permanently added 'xx.xxx.xx.xx' (ECDSA) to the list of known hosts.
Permission denied (publickey).***
lost connection
ERROR: Job failed: exit code 1

我错过了什么?

最佳答案

仔细检查您是否有正确的ssh密钥,并在不切断任何字符的情况下复制它们。你能用这些钥匙手动连接吗?例如,将它们添加到local.ssh/config并尝试将其ssh到vm中。

10-07 14:55