azure-devops - SSH 文件复制 - 不允许使用公钥
问题描述
获得了我们自己的 Linux 服务器构建/发布池。我在管道中有一项任务,通过 ssh 将文件复制到远程服务器。
在构建服务器上,作为代理运行的服务帐户用户,我运行ssh-keygen
. 点击进入所有问题。
我将构建代理.ssh/id_rsa.pub
文件复制到.ssh/authorized_keys
远程服务器上。
我确保在远程服务器上相应地设置了权限(仅限用户 rw)。
在构建服务器上,作为构建代理我运行:
ssh user@remoteserver
而且我没有密码就登录了。惊人的!密钥交换工作!
然后,我在 Azure DevOps 和“通过 SSH 复制文件”任务中创建一个服务连接,指定要使用的远程用户的服务连接,并提供远程服务器用户的私钥。
管道失败:
2019-08-09T21:15:05.7510316Z ##[error]Error: Failed to connect to remote machine. Verify the SSH service connection details. Failed to connect to remote machine. Verify the SSH service connection details. Error: All configured authentication methods failed..`
我在远程服务器上启用DEBUG3
模式并在日志中看到此消息:
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug3: mm_answer_keyallowed entering
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug3: mm_answer_keyallowed: key_from_blob: 0x560ecb33c5f0
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug1: temporarily_use_uid: 52139/52139 (e=0/0)
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug1: trying public key file /home/buildagent/.ssh/authorized_keys
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug1: fd 9 clearing O_NONBLOCK
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug2: key not found
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug1: restore_uid: 0/0
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug3: mm_answer_keyallowed: key 0x560ecb33c5f0 is not allowed
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: Failed publickey for buildagent from 10.251.80.6 port 57726 ssh2: RSA SHA256:PTyAT4hagIZCh2QM8lDvOneF0BIlu6wCiGdfH/Ro5no
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug3: mm_request_send entering: type 23
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa [preauth]
Aug 9 15:16:54 vwc1uewbapp52 sshd[63105]: debug3: userauth_finish: failure partial=0 next methods="publickey,gssapi-keyex,gssapi-with-mic,password" [preauth]
为什么它可以手动工作,使用相同的用户,而不是作为管道运行时?
解决方案
推荐阅读
- api - Wikipedia API 不返回某些标题的图像
- r - 如何清理 col 并且只保留 # 和 number
- angular - 如何将对象数组值传递给 queryParams
- c# - 在 .Net Core 3.1 上启用 antiForgery 会导致 BadRequest
- python - 通过 azure 自动化 Runbook 连接 azure blob 存储的 Python 代码
- mysql - MySQL - 编写一个 sql 查询来转置获取的记录?
- r - 获取 json 时如何接受 gdpr cookie?
- python - Scipy锯齿波非恒定峰值
- c# - 当没有聚合时,域逻辑应该去哪里?
- c# - 使用linq c#在datagridview中显示特定记录