1827457 Members
5790 Online
109965 Solutions
New Discussion

telnet in a script

 
SOLVED
Go to solution
Pippo_9
Frequent Advisor

telnet in a script

Hello,

is it possible to create a script with telnet included and bypass the password request?
Have you ever created a similar script? Have you experiencies about this?

Thanks in advance for your helps!

Kind regards,
Pedro
6 REPLIES 6
David Burgess
Esteemed Contributor

Re: telnet in a script

Pedro,

Take a look at the man page for remsh. With the use of /.rhosts or /etc/hosts.equiv you can log in and run remote commands without the need for a password.

To do this as root, on the server (server1) add .rhosts with an entry like

client1 root

Permissions should be r only for root so

chmod 400 /.rhosts

On client1

#remsh server1 -l root -n "ls -l /.rhosts"

-r-------- 1 root sys 42 Mar 5 16:45 /.rhosts

Regards,

Dave.
Sanjay Kumar Suri
Honored Contributor

Re: telnet in a script

Not sure about telnet.

However commands starting with letter r (rlogin, rcp, remsh) can be used on a network using /etc/hosts.equiv or .rhosts file.

There are security issues which need to looked into before doing this.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Karthik S S
Honored Contributor

Re: telnet in a script

Hi,

Yes it is possible with expect. Refer to my earlier thread on this topic,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=45609

Regards,
KarthiK S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Pippo_9
Frequent Advisor

Re: telnet in a script

Ok guys, thanks for suggestions!
I am looking for...

Kind regards,
Pedro
Chris Wilshaw
Honored Contributor

Re: telnet in a script

There is a way using telnet's "TAC" facility (see the telnetd man page), although this should be considered as a potential security risk.

To set it up, change the telnetd line in /etc/inetd.conf to read

telnet stream tcp nowait root /usr/lbin/telnetd telnetd -t

then restart inetd (inetd -c)

This then enables telnet sessions to use standard equavalency via the hosts.equiv file.

The security issue with this is that it connects to the remote server using the UID number, rather than the user name.

eg: you have 2 servers server1 and server2. On server1, userA has UID number 123 and userB has UID 456, on server2, userB has UID number 123, and userA has UID 456

If TAC is enabled, when userA issues the telnet command to connect from server1 to server2, they actually log in to server2 as userB, even though the ID userA exists
Ron Kinner
Honored Contributor
Solution

Re: telnet in a script

Following is a working script which we use at work with only the IP address and login/password changed. This logs into a 3COM switch and makes a few changes then exits. The \r's were needed by the 3Com but my Ciscos don't need them.

REMOTE=A.B.C.D
(sleep 5
echo "\r"
sleep 1
echo "login\r"
sleep 1
echo "password\r"
sleep 3
echo "ethernet portState 2 disable\r"
sleep 1
echo "ethernet portState 1 enable\r"
sleep 1
echo "ethernet sum all\r"
sleep 2
echo "q\r"
sleep 1
echo "logout\r"
echo "\r") |telnet $REMOTE

Ron