简体   繁体   English

加载密钥“/root/.ssh/pipelines_id”:格式无效

[英]Load key "/root/.ssh/pipelines_id": invalid format

I am using bitbucket pipeline to deploy app on a ec2-server.我正在使用 bitbucket 管道在 ec2-server 上部署应用程序。

here is my bitbucket-pipelines.yaml file这是我的 bitbucket-pipelines.yaml 文件

image: atlassian/default-image:3

pipelines:
  branches:
    dev:
      - step:
          name: automated deployment
          script:
            - pipe: atlassian/scp-deploy:1.2.1
              variables:
                USER: 'ubuntu'
                SERVER: $SERVER_IP
                REMOTE_PATH: '/home/ubuntu/utags-test/server'
                LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/*' 
            - pipe: atlassian/ssh-run:0.4.1
              variables:
                SSH_USER: 'ubuntu'
                SERVER: $SERVER_IP
                COMMAND: 'cd /home/ubuntu/utags-test/server;docker pull paranjay1/utags-paranjay:dev;docker-compose down;docker-compose up -d'
                SSH_KEY: $SERVER_PRIVATE_KEY 
                DEBUG: 'true'
          services:
            - docker   

error while running pipeline运行管道时出错

Build setup13s

pipe: atlassian/scp-deploy:1.2.1
....
....
Digest: sha256:b9111f61b5824ca7ed1cb63689a6da55ca6d6e8985eb778c36a5dfc2ffe776a8
Status: Downloaded newer image for bitbucketpipelines/scp-deploy:1.2.1
INFO: Configuring ssh with default ssh key.
INFO: Adding known hosts...
INFO: Appending to ssh config file private key path
INFO: Applied file permissions to ssh directory.
✔ Deployment finished.

pipe: atlassian/ssh-run:0.4.1
....
....
Digest: sha256:b8ff5416420ef659869bf1ea6e95502b8fa28ccd5e51321e4832d9d81fdefc18
Status: Downloaded newer image for bitbucketpipelines/ssh-run:0.4.1
INFO: Executing the pipe...
INFO: Using passed SSH_KEY
INFO: Executing command on 13.235.33.118
ssh -A -tt -i /root/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22 ubuntu@13.235.33.118 bash -c 'cd /utags-test/server;docker pull paranjay1/utags-paranjay:dev;docker-compose down;docker-compose up -d'
Load key "/root/.ssh/pipelines_id": invalid format
Load key "/root/.ssh/pipelines_id": invalid format
ubuntu@13.235.33.118: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
✖ Execution failed.
  • I already installed docker and docker-compose on my ec2-server我已经在我的 ec2-server 上安装了 docker 和 docker-compose
  • I generated the keys on bitbucket in sshkey section and added bitbucket public key to my authorized_keys file on ec2-server我在 bitbucket 上生成了 sshkey 部分的密钥,并将 bitbucket 公钥添加到我在 ec2-server 上的 authorized_keys 文件中
  • $SERVER_PRIVATE_KEY contains the ec2-server private key $SERVER_PRIVATE_KEY 包含 ec2-server 私钥
  • $SERVER_IP contains my ec2-server public IP $SERVER_IP 包含我的 ec2-server public IP

HOW CAN I SOLVE THIS ISSUE and what might be the cause of this error?我该如何解决这个问题,这个错误的原因可能是什么?

atlassian/ssh-run pipe documentation states the alternative SSH_KEY should be base64 encoded. atlassian/ssh-run pipe 文档指出替代的 SSH_KEY 应该是 base64 编码的。 My bet is you missed that info bit.我敢打赌你错过了那个信息位。

An base64 encoded alternate SSH_KEY to use instead of the key configured in the Bitbucket Pipelines admin screens (which is used by default).一个 base64 编码的备用 SSH_KEY,用于代替 Bitbucket 管道管理屏幕中配置的密钥(默认使用)。 This should be encoded as per the instructions given in the docs for using multiple ssh keys .这应该按照文档中给出的使用多个 ssh 密钥的说明进行编码。

Another good question would be: why aren't you using the ssh key provided by the pipeline instead?另一个好问题是:为什么不使用管道提供的 ssh 密钥呢?

You can use repository SSH key, so you won't need to encode it.您可以使用存储库 SSH 密钥,因此您无需对其进行编码。

bitbucket.com/.../admin/addon/admin/pipelines/ssh-keys bitbucket.com/.../admin/addon/admin/pipelines/ssh-keys

Then remove SSH key variable and it defaultly uses repository ssh key.然后删除 SSH 键变量,它默认使用存储库 ssh 键。

you actually don't need to use "SSH_KEY: $SERVER_PRIVATE_KEY" in your pipe. you can use the default keys available in your bitbucket_repo > repository_settings > ssh_key.您实际上不需要在 pipe 中使用“SSH_KEY: $SERVER_PRIVATE_KEY” 。您可以使用 bitbucket_repo > repository_settings > ssh_key 中可用的默认密钥。 you can generate a key here.你可以在这里生成一个密钥。 the generated public key should be in the remote server's "/home/ubuntu/.ssh/authorized_key" file.生成的公钥应该在远程服务器的“/home/ubuntu/.ssh/authorized_key”文件中。 add your remote servers public-IP to the known host and fetch fingerprint.将您的远程服务器公共 IP 添加到已知主机并获取指纹。

but if you want to use a different ssh key then you have to add "SSH_KEY: $SERVER_PRIVATE_KEY" in your pipe. where,但是,如果您想使用不同的 ssh 密钥,则必须在 pipe 中添加“SSH_KEY: $SERVER_PRIVATE_KEY”。其中,

$SERVER_PRIVATE_KEY - local machine's private_IP encoded to base64 $SERVER_PRIVATE_KEY -本地机器的 private_IP 编码为 base64

you have to use $base64 -w 0 < my_ssh_key command to encode your key to base64您必须使用$base64 -w 0 < my_ssh_key命令将密钥编码为 base64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker 加载密钥“/root/.ssh/id_rsa”:格式无效 - Docker Load key "/root/.ssh/id_rsa": invalid format Docker 容器构建与 git ssh 访问,加载密钥“/root/.ssh/id_rsa”:无效格式 - Docker container build with git ssh access, Load key “/root/.ssh/id_rsa”: invalid format Git 推送 SSH 远程错误:加载密钥“/path/to/file_id_rsa”:格式无效 - Git push with SSH remote error: Load key "/path/to/file_id_rsa": invalid format 对于 ssh 连接,在 Anaconda、Windows 中出现错误“无法加载密钥 ----,格式无效,权限被拒绝(公钥)” - For ssh connection, getting error "Failed to load key ----, invalid format, Permission denied (publickey)" in Anaconda, Windows 如何在 Mac 终端上通过 ssh 登录使用私钥? 我的尝试导致`加载密钥“/path/to/privatekey”:无效格式` - How to use private key with ssh login on Mac terminal? My attempts result in `Load key “/path/to/privatekey”: invalid format` id_rsa.pub 文件 SSH 错误:格式无效 - id_rsa.pub file SSH Error: invalid format key_load_public:格式无效 - key_load_public: invalid format “Key_load_pubic:格式无效” - "Key_load_pubic: Invalid Format" ubuntu 19.10 上 git 访问 ssh-add 的无效密钥格式 - invalid key format for git access ssh-add on ubuntu 19.10 GitLab CI 失败,SSH 错误加载密钥格式无效 - GitLab CI failing with SSH error loading key invalid format
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM