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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:22:21+00:00 2026-06-15T20:22:21+00:00

Possible Duplicate: Using expect to pass a password to ssh I want to have

  • 0

Possible Duplicate:
Using expect to pass a password to ssh

I want to have ssh connection to a remote machine and instead of using ssh command along with the machine address and password, I just want to write a little function that executes the ssh command to the machine and enters the pass after the server asks it. I can write the ssh part but how can I make the script that enters also the pass when the host ask for it?

  • 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-06-15T20:22:22+00:00Added an answer on June 15, 2026 at 8:22 pm

    You may use expect script. You can pass arguments from cmd line. Sample code I write:

    #!/usr/bin/expect
    
    set timeout 100
    set host [lindex $argv 0]
    set username [lindex $argv 1]
    set password [lindex $argv 2]
    set command [lindex $argv 3]
    
    spawn ssh $username@$host $command
    #puts $command
    expect {
        "(yes/no)?"
            {
                send "yes\n"
                expect "*assword:" { send "$password\n"}
            }
        "*assword:"
            {
                send "$password\n"
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Using a bitwise & inside an if statement I have the following
Possible Duplicate: Using IoC for Unit Testing I think I do have a Problem
Possible Duplicate: Using a relative path in connection string for Access DB in C#
Possible Duplicate: Using Git how do I find modified files between local and remote
Possible Duplicate: How to quickly set up Git for teams using Xcode? I have
Possible Duplicate: Dynamically-generated table-name in PostgreSQL COPY command I am using the copy to
Possible Duplicate: using legacy assemblies in metro style app I have downloaded and installed
Possible Duplicate: using seo user friendly in php I have 3 PHP files: index1.php,
Possible Duplicate: Using A* to solve Travelling Salesman Problem I have recently learned that
Possible Duplicate: jquery: on vs live I have code that works just fine using

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.