我正在尝试 scp 一些文件,然后 ssh 进入远程服务器。从本地主机工作正常。但是,当我通过 Jenkins 中的 shell 脚本尝试相同的操作时,ssh 会话会卡住或关闭。我尝试通过散列 sab 命令单独运行 scp 命令,并且效果很好。我在控制台输出结束时收到 debug1: Exit status 0。
我试图运行的命令是:
sshpass -p 0pen5ecret scp -v -o StrictHostKeyChecking=no
/home/jenkins/test_folder/${env}_test.properties
servername@${server}:/home/
接着,
sshpass -p password ssh -tt -o StrictHostKeyChecking=no
servername@${server} 'cd /home ; rm -f cachefolder ; sh test.sh'
以下是我在控制台输出中收到的错误消息:
debug1: Host '172.21.83.215' is known and matches the RSA host key.
debug1: Found key in /var/lib/jenkins/.ssh/known_hosts:9
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-
interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /var/lib/jenkins/.ssh/id_rsa
debug1: Trying private key: /var/lib/jenkins/.ssh/id_dsa
debug1: Trying private key: /var/lib/jenkins/.ssh/id_ecdsa
debug1: Trying private key: /var/lib/jenkins/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
debug1: Authentication succeeded (keyboard-interactive).
Authenticated to 172.21.83.244 ([172.21.83.210]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -t /data01/DS_Release
Sending file modes: C0777 123 TS2_DeploymentScore.properties
Sink: C0777 123 TS2_DeploymentScore.properties
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: fd 2 clearing O_NONBLOCK
Transferred: sent 3320, received 4596 bytes, in 0.1 seconds
Bytes per second: sent 54147.4, received 74958.3
debug1: Exit status 0
如何解决?提前致谢。顺便说一句,这是我在这里的第一个问题,所以很好。