LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (http://www.linuxquestions.org/questions/ubuntu-63/)
-   -   i want to create a script for automatic login through telent (http://www.linuxquestions.org/questions/ubuntu-63/i-want-to-create-a-script-for-automatic-login-through-telent-943340/)

ashu_ky 05-04-2012 08:38 PM

i want to create a script for automatic login through telent
 
Hi all,
please help me our here.
i have ubuntu desktop.
i use to login into my server through.
there are many server like this.
i want script for automatic login. ( script should enter automation uid/pwd)
logs are below.
#########################################################################
eashuku@GH4WVQ1:~$ telnet 150.236.xx.xx
IN-XXXXXX login: test
Password: test
Last login: Sat May 5 05:47:48 UTC 2012 from 169.144.8.16 on pts/0
############################## XXXXXXXXX #########################################

This System is for authorized users only. All activity is logged and regulary checked by systems personal.
Individuals using this system without authority are subjected to having all their services revoked.

####################################################################################################
test@IN-XXXXXX:~> mdsh
MDSH>

smallpond 05-04-2012 09:04 PM

This is pretty much what expect was designed for. Install it if you don't have it and it's trivial to script telnet login.

ashu_ky 05-05-2012 12:31 PM

I need simple bin/bash script !

TobiSGD 05-05-2012 12:37 PM

1. Yelling at people will make them less likely to help you.
2. There is no simple bash script to do this with telnet
3. telnet is outdated and totally insecure. Switch to SSH and use key-based authentication (recommended anyways), this way you don't need to type in a password and can use simple scripts to automate tasks.

pan64 05-05-2012 12:38 PM

you will never get a simple bash script because telnet requires interactivity (so you need to wait for a prompt, send username, wait for another string, send password and finally you will need to send the command and wait for the answer). Bash is not designed to do that. The program you need is named expect.
From the other hand you can do it easily with ssh, instead of telnet.

jefro 05-05-2012 01:23 PM

autoexpect is on may distro's. It tends to work fine for creating such scripts.

Makes a expect script as easy as can be.

ashu_ky 05-05-2012 01:23 PM

okay buddy,
please tell me.

ssh user@150.xx.xx.xx with password test.

what should be script?

my scipt

!bin/bash
ssh user@150.xxxxxx
echo pasword;
------------------------------> not working :(

TobiSGD 05-05-2012 01:33 PM

As said already before, use key-based authentication and you don't need to type in a password.

ashu_ky 05-05-2012 01:52 PM

Dear friend,
my limitation is that , i can not make any change in server and as well as i don't have root access on client machine. anyways i can use Sudo.

its Ubunutu11.04.

looking for your kind response.

pan64 05-05-2012 02:08 PM

you do not need root account if ssh installed.
you only need to configure the user you want to use.

TobiSGD 05-05-2012 02:11 PM

If you can use sudo you have root access
Code:

sudo -i
will give you a root shell. Why can't you make changes to the server? If it is company policy ask your IT department why you have to use a service that is deprecated for years and known to be totally insecure and if they can install and configure SSH, since you don't want to use services that may make it possible to break into the company's systems.


All times are GMT -5. The time now is 11:48 PM.