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.
© 2024 OneMinuteCode. All rights reserved.