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

  • Home
  • SEARCH
  • 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 4344722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:56:14+00:00 2026-05-21T11:56:14+00:00

Here is the story. I have a Debian 5 server automatically starting into a

  • 0

Here is the story.
I have a Debian 5 server automatically starting into a local user account.
The local user account has the following .profile

#!/bin/bash

SERVERPASS="password"
function with_password {
expect << END
set timeout 900
spawn $2
expect *assword:*
send -- "${1}\r"
expect EOF
exit 0
END
}

cd /home/timecard
with_password $SERVERPASS "ssh timecard@192.168.254.5 -p 22"

This then connects to the remote computer as user timecard.

However the issue is that I cannot interact normally with it. When I type, the text does not stay within my program on the remote computer.

When I connect manually however, it works just fine.

So how do I mimic the manual login to the server using the expect command? Am I missing a command?

P.S.
Yes I know automatic logins are bad, I know that ssh autologin is bad, etc…

  • 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-21T11:56:14+00:00Added an answer on May 21, 2026 at 11:56 am

    The problem here is the expect EOF, I think. This means your expect call only will return when you already logged off, so you can’t send any keys to this.

    Does the same work without this line?

    But of course, use public-key authentication instead of automatic password login.


    The following expect script works for me with ssh (I don’t have password authentication enabled, so I’m using the “do you want to allow the host key” question instead):

    #!/usr/bin/expect -f
    
    system ssh-keygen -R localhost
    spawn ssh -o StrictHostKeyChecking=ask localhost
    expect "(yes/no)? "
    send -- "yes\n"
    interact
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I ran into recently. I have attributes strings of the form
Here is the story. I was doing a program, every time the program is
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Let say I have the following desire, to simplify the IConvertible's to allow me
Here is the code to add a pfx to the Cert store. X509Store store
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see

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.