Solved

Automated telnet -and yes!! I am crazy.

Posted on 2001-07-31
6
162 Views
Last Modified: 2010-03-18
I have several machines on an internal network that is DMZ and some level of promisquiety is allowed.

Is it possible to write a script that can automatically feed a Telnet prompt Username and Password ?
Username is easy but password is a bit troublesome.

Please present a script which will when executed log you in if you have password and username as variables in the script.
0
Comment
Question by:dryzone
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:superschlonz
Comment Utility
Im using expect (http://expect.nist.gov/) for things like that.
It's a TCL/Tk interpreter with some added functionality for running an controlling processes.
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Why bother with that. Given the description of what you have and want to do it would make just as much sense to configure the systems for rlogin or ssh access using rhosts. In that case no password would be required for those users/machines permitted access that way.

Personally I'd generate a keypair with ssh-keygen (with no passphrase) and place the public key in .ssh/authorized_keys2 on the remote system. That allows me to simply say "ssh remote-host" and be instantly logged in without having to supply a password. It's far more secure than using rhosts files or hosts.equiv and has the bonus of using an encrypted session.
0
 
LVL 1

Author Comment

by:dryzone
Comment Utility
jleve.
Yes I am running SSH on my firewall for whenever I am outside.
However, the ssh behaviour as you describe could never be implimented. Passwords were always required. You are right about using ssh, but it is slow compared to telnet  and I am in a DMZ.
sure rlogin.......still needs a password.

Both superschlonz and jleve.
Give me a script which I enter username and password and when I run it I am logged in and you have the points.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 40

Accepted Solution

by:
jlevie earned 100 total points
Comment Utility
If you really want to do this with telnet the following will work. You'll need to edit the file and change "my-name" and "my-passwd" to the user name and password on the remote system. Also you'll want to make the file owned by yourself and set it to mode 700.

#!/usr/bin/expect --
# Simple script to open a telnet session on a remote host. The script will
# exit when you log out of the remote. It expects the host name on the
# command line, e.g., "this-script remote-server".
#
set host [lindex $argv 0]
set timeout 60
spawn telnet $host
expect "ogin:"
send "my-name\r"
expect "assword:"
send "my-passwd\r"
interact

If you were getting a password prompt using ssh then something didn't get set up properly. First of all you need to be using a recent copy of OpenSSH that supports SSH 2. Then on the local system execute:

illusion> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jlevie/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/jlevie/.ssh/id_rsa.
Your public key has been saved in /home/jlevie/.ssh/id_rsa.pub.
The key fingerprint is:
9a:fa:78:ac:....
illusion>

At the passphrase prompts just hit return. Add the contents of .ssh/is_rsa.pub to ~/.ssh/authorized_keys2 on the remote system. That's easily done after copying the file to the remote with:

remote> cat ip_rsa.pub >>.ssh/authorized_keys2

Then from the local system just execute "ssh remote". You won't get a  passwd request and will be logged in. Another nice thing about this is that it also works for scp and when using ssh to execute commands on the remote... Much more powerful than using an expect script to establish a telnet session.
0
 
LVL 1

Author Comment

by:dryzone
Comment Utility
Looked good but did not work.
Expect is in /usr/bin so that works.
HGowever the script failed.


[Lht@gateway Lht]$ ./loginhelper
spawn telnet
usage: telnet [-l user] [-a] host-name [port]
send: spawn id exp4 not open
    while executing
"send "Lht\r""
    (file "./loginhelper" line 10)
[Lht@gateway Lht]$
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
The script expects the host name of the remote system as an argument, so execute it as "loginhelper remote-name". My presumption was that you'd have the same name and password on each of the DMZ systems and you could then use one script and specify the system on the command line.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
FTP File Transfer Failure 13 114
ESXi NTP client time synch is not working 3 51
iptables ubuntu BLOCK all 2 74
Linux SSH Error 9 67
I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now