I was wondering if it is possible to use an asked password for the ssh login, the interaction_handler
doesn't seem to work for this task. So far I have:
ask :ip, 'Enter the ip of the server: '
fetch(:ip)
ask :pw, 'Enter user password: ', echo: false
fetch(:pw)
on "user@" + fetch(:ip) do
execute "echo 'Hi.'", interaction_handler: {"user@#{fetch(:ip)}'s password" => "#{fetch(:pw)}\n"}
end
On that execute line, it tries to log into the server and the server prompts for the password. How can I supply it with the one stored in :pw
?
Answer turned out to be in https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md
host = SSHKit::Host.new('[email protected]')
host.password = "hackme"
on host do |host|
puts capture(:echo, "I don't care about security!")
end