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 5962461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:06:32+00:00 2026-05-22T19:06:32+00:00

In a previous question I figured out how to start a password-authenticated ssh sessions

  • 0

In a previous question I figured out how to start a password-authenticated ssh sessions on multiple servers to run a single command. Now I need to be able to execute a “sudo” command. The problem is, that net-ssh-multi does not allocate a pseudo terminal (pty), which sudo needs to run, resulting in the following error:

[127.0.0.1 : stderr] sudo: sorry, you must have a tty to run sudo

According to the documentation, a pseudo-terminal can be allocated with a method call to a channel object, however, the following code does not work: it generates the “no tty” error above:

require 'net/ssh'
require 'net/ssh/multi'

Net::SSH::Multi.start do |session|


  # define the servers we want to use
  my_ticket.servers.each do |session_server|
    session.use session_server , :user =>  user_name ,  \
                              :password => user_pass
  end


 # execute commands on all servers
  session.exec 'sudo ls /root' do |channel, stream, data|
   if data =~ /^\[sudo\] password for user:/
     channel.request_pty # <- problem must be here.
     channel.send_data user_pass
   end

  end

 # run the aggregated event loop
 session.loop
end

$ ruby –version

ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]

  • 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-22T19:06:33+00:00Added an answer on May 22, 2026 at 7:06 pm

    Can you try something like this:

      channel.request_pty do |c, success|
        if success
          command = "sudo YOUR_COMMAND"
          c.exec(command) do |c, success|
            # Some processing
          end
        end
      end
    

    In this case ‘sudo’ is inside.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, As a followup to my previous question about Moose, I've now run into
In a previous question, I asked about various ORM libraries. It turns out Kohana
In a previous question about overriding Time.now , I was working toward a solution
This question is directly related to my previous question ASP.NET AJAX Is it possible
this question is an extension to a previous question i asked (and was answered).
This question is a follow up to my previous question about getting the HTML
Continuing from my previous question , is there a comprehensive document that lists all
Going back to my previous question on OCSP, does anybody know of reliable OCSP
From a previous question I have seen that the CLR has workstation and server
We determined in a previous question that many features of HTML SELECTs are not

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.