我正在尝试使用 Windows 中的 Jenkins 构建自动备份。配置是:
- Windows 7的
- 詹金斯 1.594
- 腻子工具 beta 0.63
我在非特权“jenkins”用户下将 Jenkins 作为服务运行。我已经创建了一个公钥/私钥对并将其上传到 SSH 服务器,并且我已经验证我能够在使用 jenkins 用户登录时加载的私钥运行选美时无需通知用户密码即可登录。
Jenkins 构建调用一个批处理脚本,该脚本使用 plink 在 SSH 服务器上运行 postgres 备份,然后运行 pscp 以在本地复制备份。问题是,如果我通过命令行运行与 jenkins 用户相同的脚本,一切正常,但是当通过 Jenkins 调用脚本时,它似乎没有检测到选美正在运行。jenkins 用户有一个正在运行的选美活动会话。
问题是:如何让 plink/pscp 找到选美实例?
手动运行输出:
plink -v -batch -agent -l user -P 22 <IP> "<COMMAND>"
Looking up host "<IP>"
Connecting to <IP> port 22
Server version: SSH-2.0-OpenSSH_5.3
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.63
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 2048 <FINGERPRINT>
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using username "user".
Trying Pageant key #0
Authenticating with public key "jenkins@build" from agent
Sending Pageant's response
Access granted
Opening session as main channel
Opened main channel
Started a shell/command
...
詹金斯运行输出:
plink -v -batch -agent -l user -P 22 <IP> "<COMMAND>"
Looking up host "<IP>"
Connecting to <IP> port 22
Server version: SSH-2.0-OpenSSH_5.3
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.63
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 2048 <FINGERPRINT>
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "user".
Using SSPI from SECUR32.DLL
Attempting GSSAPI authentication
GSSAPI authentication request refused
Disconnected: Unable to authenticate