You might want to examine something like expect
, which would allow you to do something like this:
spawn vpn_connect.sh
expect "Auth User name:"
send "protractor-container\r"
expect "Password:"
send "superSecretPassword!123\r"
Of course this might not be ideal in the event a number of people have the ability to connect to the Docker container or read the source files that get packaged in the build, as clear text passwords can create problems.
One option would be to create a separate file that contains the credentials and store it in a location within the Docker container, such as /root/.private/vpn-creds
. This file would contain just two lines:
protractor-container
superSecretPassword!123
Then you can edit your expect
script to look like this:
#!/usr/bin/expect -f
set passfile [open "/root/.private/vpn-creds" r]
gets $passfile username
gets $passfile password
close $passfile
spawn vpn_connect.sh
expect "Auth User name:"
send "$username\r"
expect "Password:"
send "$password\r"
Mind you, if everyone has root
access, there’s not much you can do in an automated fashion to hide the credentials. A determined person with sudo
who knows how to use StackExchange will find a way to get the information they want