Expect telnet password is exposed

Discussion in 'Perl Misc' started by Ajay, Feb 10, 2004.

  1. Ajay

    Ajay Guest

    Finally getting hookedup to expect :)
    Here is the script i got to start with, it's working fine. I got it frm this NG.
    Now i want to modify it to suit my taste.
    1) I want to create a new xterm window from this script then telnet into the
    remote server and then run the other commands.
    2) In the script i have to expose password. How to amke it secure secure it ?
    Any help will be appreciated.

    Tx
    Ajay

    #!/opt/exp/bin/expect -f

    set name "myname"
    set password "XYZ"
    set host "server1"
    set prompt_regexp "\\$"
    set timeout 60

    spawn telnet $host

    expect {
    login: {
    send "$name\n"
    } timeout {
    send_user "connection to $host timed out.\n"
    exit
    } eof {
    send_user "connection to $host failed: $expect_out(buffer).\n"
    exit
    }
    }

    expect {
    Password: {
    send "$password\n"
    } timeout {
    send_user "connection to $host timed out.\n"
    exit
    } eof {
    send_user "connection to $host failed: $expect_out(buffer).\n"
    exit
    }
    }
    Ajay, Feb 10, 2004
    #1
    1. Advertising

  2. Ajay

    Ben Morrow Guest

    Ajay <> wrote:
    > Finally getting hookedup to expect :)
    > Here is the script i got to start with, it's working fine. I got it frm this NG.


    > #!/opt/exp/bin/expect -f


    I find that unlikely: this is a Perl ng.

    > Now i want to modify it to suit my taste.
    > 1) I want to create a new xterm window from this script then telnet into the
    > remote server and then run the other commands.


    You need to create a shell script that runs

    xterm -e /path/to/expect/script

    > 2) In the script i have to expose password. How to amke it secure secure it ?


    You're using telnet, so you're screwed anyway wrt security. In
    general, you can either ask the user for the password each time (and
    no, I don't know if/how you can do that in expect) or just make sure
    the read permissions on the script are as tight as possible.

    Ben

    --
    Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
    From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
    (Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
    /Alcestis/) [ flame, and falls out of sight. ]
    Ben Morrow, Feb 10, 2004
    #2
    1. Advertising

  3. Ajay

    Ajay Guest

    Ben Morrow wrote:
    >
    > Ajay <> wrote:
    > > Finally getting hookedup to expect :)
    > > Here is the script i got to start with, it's working fine. I got it frm this NG.

    >
    > > #!/opt/exp/bin/expect -f

    >
    > I find that unlikely: this is a Perl ng.


    kindly guide me to "expect" grp please || tell me the appropriate grp where i
    can post expect related Qs

    > > Now i want to modify it to suit my taste.
    > > 1) I want to create a new xterm window from this script then telnet into the
    > > remote server and then run the other commands.

    >
    > You need to create a shell script that runs
    >
    > xterm -e /path/to/expect/script

    Yeh that's what i do. But i think i can do a fork and run telnet and other
    commands inside that process. Still hunting Google...

    > > 2) In the script i have to expose password. How to amke it secure secure it ?

    >
    > You're using telnet, so you're screwed anyway wrt security. In
    > general, you can either ask the user for the password each time (and
    > no, I don't know if/how you can do that in expect) or just make sure
    > the read permissions on the script are as tight as possible.

    i saw somewhere ppl talking about ssh.
    how to do it into ssh ?
    > Ben

    Tx for reply
    >
    > --
    > Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
    > From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
    > (Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
    > /Alcestis/) [ flame, and falls out of sight. ]
    Ajay, Feb 10, 2004
    #3
  4. Ajay

    Ben Morrow Guest

    Ajay <> wrote:
    > Ben Morrow wrote:
    > > Ajay <> wrote:
    > >
    > > > #!/opt/exp/bin/expect -f

    > >
    > > I find that unlikely: this is a Perl ng.

    >
    > kindly guide me to "expect" grp please || tell me the appropriate grp where i
    > can post expect related Qs


    You will find that politeness and full English sentences will get you
    a long way in life. Try comp.lang.tcl (IIRC expect is written in or
    for tcl), but don't blame me if it's wrong.

    Ben

    --
    If I were a butterfly I'd live for a day, / I would be free, just blowing away.
    This cruel country has driven me down / Teased me and lied, teased me and lied.
    I've only sad stories to tell to this town: / My dreams have withered and died.
    <=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=> (Kate Rusby)
    Ben Morrow, Feb 10, 2004
    #4
  5. Ajay <> wrote:
    > Ben Morrow wrote:
    > > Ajay <> wrote:
    > > > #!/opt/exp/bin/expect -f

    > > I find that unlikely: this is a Perl ng.

    > kindly guide me to "expect" grp please || tell me the appropriate grp where i
    > can post expect related Qs


    comp.lang.tcl


    --
    Glenn Jackman
    NCF Sysadmin
    Glenn Jackman, Feb 10, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Isaacson
    Replies:
    5
    Views:
    593
    Default User
    Nov 5, 2004
  2. AAaron123
    Replies:
    2
    Views:
    2,097
    AAaron123
    Jan 16, 2009
  3. Simon Strandgaard

    how to expect eof with expect+pty

    Simon Strandgaard, Dec 20, 2006, in forum: Ruby
    Replies:
    4
    Views:
    336
    Simon Strandgaard
    Dec 20, 2006
  4. Carcarius
    Replies:
    0
    Views:
    275
    Carcarius
    Dec 6, 2007
  5. Phil
    Replies:
    0
    Views:
    155
Loading...

Share This Page