Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:52+00:00 2026-05-26T16:22:52+00:00

I am looking to execute a password change over Net-ssh and this code seems

  • 0

I am looking to execute a password change over Net-ssh and this code seems to hang:

Net::SSH.start(server_ip, "user", :verbose => :debug ) do |session|

  session.process.popen3("ls") do |input, output, error|

    ["old_pass","test", "test"].each do |x|

        input.puts x

    end

  end

end

I know the connection works because using a simple exec I can get the output from ls on the remote server, but this hangs.

Any ideas?

The last message from debug is that the public key succeeded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:22:52+00:00Added an answer on May 26, 2026 at 4:22 pm

    This one will solve your issue ,, note this script to change password for a list of servers list in file

    #~~~~~~~~~~~~~~~~~~~~~~~
    # Change  Password is a simple script to change the password for a list of servers 
    # Coded by : Sabry Saleh
    # License : GPL2
    #~~~~~~~~~~~~~~~~~~~~~~~
    #=-Notes-=
    # You have to install ruby + net-ssh gems 
    # sudo gem install net-ssh
    #~~~~~~~~~~~~~~~~~~~~~~~
    
    require 'net/ssh'
    
    host = IO.readlines('test1.txt') # full path of servers' list
    port = 22       # SSH port
    user = 'username'   # username
      i  = 0
    
    while i < host.length 
    
      Net::SSH.start(host[i], user , :password => "User pass" , :port=> port) do |ssh|
        ssh.open_channel do |channel|
        channel.on_request "exit-status" do |channel, data|
          $exit_status = data.read_long
        end
          channel.request_pty do |channel, success| 
          channel.exec("sudo passwd UserName")  # Logged user shuold be root or sudoers memeber
          if success
            channel.on_data do |channel, data|
              puts data.inspect.chomp("\r\n")
              channel.send_data("New pass\n") # put the New password you need to set
              sleep 0.1
            end
          else
            puts "FAILED!!"
          end
        end
        channel.wait
        puts "SUCCESS!!" if $exit_status == 0
        end
      end
    i += 1
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking for an alternative to eval() way to execute a code contained
I'm looking for an effective way to execute a method everyday at 3PM regardless
I am looking for a way to not have a plugin execute on install.
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
Looking at the C# project templates in VS2008 and the offerings are WPF User
im looking to execute to execute command line commands from objective c. I know
I'm looking to be able to always execute both validateA and validateB: function validateA()
Im looking to send command strings to a flash app, to execute debug commands.
In sh-mode in Emacs, I was looking for a way to execute a shell
I'm a new user of mysql++ looking for some pointers (pun intended). The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.