linux - Expect script: Read Base64 password from file -
i have created script connect server using sftp. avoid putting password in script plain text, i'm planning on putting in file encoded in base64. can read file no problem. don't know how decode base64 expect. so, now, script reads file , puts password (directly) script. how decode it? i'm ready move script shell/bash if there's way such thing.
thank you. here's code:
#!/usr/bin/expect set mypassword [open "sftp_auth.cfg" r] set data [read $mypassword] spawn sftp myuser@111.111.111.111 expect "*assword:" send "$data\n" expect "sftp>" send "cd /repository\n" expect "sftp>" send "get example.sh /home/user/example2.sh\n" expect "sftp>" send "exit\n" interact
you can use tcl's exec
command decode password. example:
[step 101] # cat foo.exp set base64_passwd ugfzc3cwcmq= set passwd [exec echo $base64_passwd | base64 -d] puts $passwd [step 102] # expect foo.exp passw0rd [step 103] #
Comments
Post a Comment