【问题标题】:SSH deploy from Bitbucket. Disable passphrase?从 Bitbucket 部署 SSH。禁用密码?
【发布时间】:2019-06-08 01:51:58
【问题描述】:

所以基本上我的设置是在我的远程服务器上创建一个 ssh 对,然后将 pub 密钥复制到 bitbucket,以及我的服务器的 authorized_keys 文件。

当我在 Bitbucket 上运行部署时,我的权限仍然被拒绝。

您在 Pipelines 中使用的任何 SSH 密钥都不应有密码。

我假设这与它有关,即使我使用空白密码创建了 ssh 对,我的 sshd_config 文件有:

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

我应该将其更改为是吗?

Bitbucket 的 documentation 说我应该 ssh-copy-id -i my_ssh_key user@host,但这对我来说没有意义,因为所有 ssh 生成都发生在远程或 Bitbucket 本身中。

不知道为什么这不是更清楚。

编辑:这是 bitbucket 构建的错误:

+ cat ./deploy.sh | ssh username@remote.com
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added the RSA host key for IP address ‘XXX.XXX.XX.XX’ to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).

这是我的sshd_config 的一些值:

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

【问题讨论】:

  • 您是否已将您的主机添加到已知主机?在 ssh 键下?
  • 是的,我尝试了ssh-keyscan -H bitbucket.com >> ~/.ssh/known_hosts,但仍然遇到同样的错误。为什么 Bitbucket 建议您在他们的服务器上创建配对?你不是想通过 ssh 进入你的遥控器,反之亦然吗?
  • 您可以自己添加它们,但 bitbucket 需要知道/接受您主机的指纹。因此,您还必须在 repo 的 ssh 部分中进行此设置
  • @SvenHakvoort 什么设置?意思是在您的 bitbucket 中配置的私钥和 pub 密钥?我已经添加了主机。所以仍然不确定为什么它不起作用。
  • 嗯好吧,这确实是我的意思。你能提供完整的错误/堆栈跟踪+命令吗?

标签: ssh bitbucket bitbucket-pipelines


【解决方案1】:

好的,知道了。出于某种原因,我的 ssh 逻辑倒退了。我在 Bitbucket 中重新创建了 ssh 密钥对,将公钥添加到我的远程服务器的 ~/ssh/authorized_keys 文件中,并且......我确保该文件的权限设置为 600。一旦我修复了该权限,我就有了第一个成功的构建。希望这对某人有所帮助。

【讨论】:

    猜你喜欢
    • 2016-11-20
    • 2022-01-01
    • 2019-08-24
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 2021-03-21
    • 2018-10-07
    • 2017-07-14
    相关资源
    最近更新 更多