为什么主机密钥验证失败?使用 Easy-Deploy-Bundle 部署 Symfony 和 BitBucket
Why does host key verification fail? Symfony and BitBucket Deployment with Easy-Deploy-Bundle
我正在尝试通过 BitBucket Pipelines 和 easy-corp/easy-deploy-bundle 将我的 Symfony 5 应用程序部署到我的服务器。我已按照 https://support.atlassian.com/bitbucket-cloud/docs/use-ssh-keys-in-bitbucket-pipelines/ to create an ssh key and added my server as a known host within BitBucket. I also followed the instructions at https://github.com/EasyCorp/easy-deploy-bundle/.
上的说明进行操作
当 运行 php bin/console deploy -v
时我在管道中遇到的错误是:
[...] Executing command: echo 1234353400
| err :: Host key verification failed.
In Process.php line 252:
[Symfony\Component\Process\Exception\ProcessFailedException]
The command "ssh ... -p ... 'echo 1234353400'" failed.
Exit Code: 255(Unknown error)
Working directory: /opt/atlassian/pipelines/agent/build
Output:
================
Error Output:
================
Host key verification failed.
我已经从 Symfony 添加了 public 密钥到我服务器上的文件 ~/.ssh/authorized_keys
。
我的部署配置文件 (deploy.php
) 如下所示:
<?php
use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;
return new class extends DefaultDeployer
{
public function configure()
{
return $this->getConfigBuilder()
->server('user@host:port')
->deployDir('dir')
->repositoryUrl('ssh-url')
->repositoryBranch('develop')
;
}
};
其中用户、主机、端口、目录和 ssh-url 被替换为我的凭据,在终端中通过 ssh 访问服务器时可以正常工作。
那我做错了什么? easy-deploy-bundle 是否正在访问有效的 .ssh 目录,BitBucket 将我的密钥和已知主机存储在该目录中?
我发现 StrictHostKeyChecking=no
可能是一个可能的解决方案,但我没有找到如何在 easy-deploy-bundle 中禁用它。
感谢您的帮助。
I found that StrictHostKeyChecking=no
could be a possible solution, but I didn't found how to disable it within easy-deploy-bundle.
这意味着您实际上 没有 added the remote server fingerprint to the known_hosts
。
- 要么您只添加了主机名,它需要 IP(或 vice-versa)
- 或者你是用一个账号(
~/.ssh/known_hosts
)添加的,但是插件是由另一个账号(或者root
)执行的,没有读取正确known_hosts
我正在尝试通过 BitBucket Pipelines 和 easy-corp/easy-deploy-bundle 将我的 Symfony 5 应用程序部署到我的服务器。我已按照 https://support.atlassian.com/bitbucket-cloud/docs/use-ssh-keys-in-bitbucket-pipelines/ to create an ssh key and added my server as a known host within BitBucket. I also followed the instructions at https://github.com/EasyCorp/easy-deploy-bundle/.
上的说明进行操作当 运行 php bin/console deploy -v
时我在管道中遇到的错误是:
[...] Executing command: echo 1234353400
| err :: Host key verification failed.
In Process.php line 252:
[Symfony\Component\Process\Exception\ProcessFailedException]
The command "ssh ... -p ... 'echo 1234353400'" failed.
Exit Code: 255(Unknown error)
Working directory: /opt/atlassian/pipelines/agent/build
Output:
================
Error Output:
================
Host key verification failed.
我已经从 Symfony 添加了 public 密钥到我服务器上的文件 ~/.ssh/authorized_keys
。
我的部署配置文件 (deploy.php
) 如下所示:
<?php
use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;
return new class extends DefaultDeployer
{
public function configure()
{
return $this->getConfigBuilder()
->server('user@host:port')
->deployDir('dir')
->repositoryUrl('ssh-url')
->repositoryBranch('develop')
;
}
};
其中用户、主机、端口、目录和 ssh-url 被替换为我的凭据,在终端中通过 ssh 访问服务器时可以正常工作。
那我做错了什么? easy-deploy-bundle 是否正在访问有效的 .ssh 目录,BitBucket 将我的密钥和已知主机存储在该目录中?
我发现 StrictHostKeyChecking=no
可能是一个可能的解决方案,但我没有找到如何在 easy-deploy-bundle 中禁用它。
感谢您的帮助。
I found that
StrictHostKeyChecking=no
could be a possible solution, but I didn't found how to disable it within easy-deploy-bundle.
这意味着您实际上 没有 added the remote server fingerprint to the known_hosts
。
- 要么您只添加了主机名,它需要 IP(或 vice-versa)
- 或者你是用一个账号(
~/.ssh/known_hosts
)添加的,但是插件是由另一个账号(或者root
)执行的,没有读取正确known_hosts