I want to ssh (password authentication) from Jenkins to git server

Asked 2 years ago, Updated 2 years ago, 119 views

The git server I want to use is ssh (password authentication), but
Jenkins' additional credentials settings are "ssh username and private key".

I'd like to authenticate with ssh by username and password, how can I do that?

git ssh jenkins

2022-09-30 19:46

1 Answers

I think you can write a script to automate password entry in expect.

Script Example

#!/bin/sh
USER = $1
HOSTNAME = $2
PASSWORD = $3
PROMPT = $4
COMMAND = $5

expect-c"
set timeout 60
spawn ssh${USER}@${HOSTNAME}
expect\"password:\"
send\"${PASSWORD}\n\"
expect\"${PROMPT}\"
send\"${COMMAND}\n\"
expect\"${PROMPT}\"
send\"exit\n\"
interact
"

This will look like this (for example, I'm logged in to the RHEL server)

$./sshtest.sh user 192.168.1.10 hogehoge'$' 'echo hello jenkins'
spawn ssh [email protected]
[email protected]'s password:
Last login—Fri Aug 26 20:48:52 2016 from 172.16.100.33
[[email protected]~]$ echo hello jenkins
hello jenkins
[[email protected]~]$ exit
logout
Connection to 192.168.1.10 closed.


2022-09-30 19:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.