I have a situation as i have to login to remote system and get the their hardware information. I logged in to their system i have used ssh for this i am using net-ssh gem. here is my code where i logged into and get the info
Net::SSH.start('host','user', :password => 'xxxxxx') do |ssh|
ssh.exec!("echo 'xxxxxx' | sudo -S dmidecode -s system-serial-number")
end
for getting the information I have used sudo -S dmidecode -s system-serial-number
command
it is giving the output with password for user as password for user 1.0.0
how can i remove that message?
Ihave refer this link but i also implemented it but it will taking to much time for loading how is their any other way to do this?
result = nil
session.exec!("sudo -S dmidecode -s system-serial-number") do |channel, stream, data|
if data =~ /^\[sudo\] password for user:/
channel.send_data 'your_sudo_password'
else
result << data
end
result
d
Not exactly sure what the problem is, but perhaps you want to try and use the
-p
switch to change the password prompt to an empty string: