[英]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.
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.