Ssh 如何修复gitlab Ci/CD中被拒绝的权限(公钥、密码)?
我在.gitlab-cl.yml文件中有以下简单脚本:Ssh 如何修复gitlab Ci/CD中被拒绝的权限(公钥、密码)?,ssh,gitlab,Ssh,Gitlab,我在.gitlab-cl.yml文件中有以下简单脚本: build_deploy_stage: stage: build environment: Staging only: - master script: - mkdir -p ~/.ssh - echo "$PRIVATE_KEY" >> ~/.ssh/id_dsa - cat ~/.ssh/id_dsa - chmod 600 ~/.ssh/id_dsa -
build_deploy_stage:
stage: build
environment: Staging
only:
- master
script:
- mkdir -p ~/.ssh
- echo "$PRIVATE_KEY" >> ~/.ssh/id_dsa
- cat ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- cat ~/.ssh/config
- scp myfile.js user@example.com:~
但在运行作业时,执行最后一行(scp命令),我会遇到此错误:
我花了一整天的时间,但没能把它修好。我验证了$PRIVATE_密钥存在。我在登录example.com时在gitlab上复制生成的private to private_key变量,生成了密钥对。
如何解决这个问题
请注意,它是dsa密钥。检查您对
~/.ssh
(700)及其所有文件(600)的权限
例如,您的配置文件可能具有过大的默认权限。
如果可以,:您将看到是否接受dsa密钥(对于最新版本的sshd,这可能会受到限制)。rsa会更好。默认情况下,OpenSSH 7.0及更高版本不再接受DSA密钥 委员会确认:
我修复了重新生成tsa密钥对而不是dsa密钥时的问题
尝试运行
ssh-vvvuser@example.com
和您的问题,包括ssh生成的详细输出。我修复了重新生成tsa密钥对而不是dsa时的问题keys@ace运输安全管理局?还是说rsa?
Warning: Permanently added 'example.com' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).