LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
Search this Thread
Old 05-04-2012, 07:38 PM   #1
ashu_ky
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Rep: Reputation: Disabled
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>
 
Old 05-04-2012, 08:04 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 1,498

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
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.
 
Old 05-05-2012, 11:31 AM   #3
ashu_ky
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
I need simple bin/bash script !

Last edited by ashu_ky; 05-05-2012 at 12:07 PM.
 
Old 05-05-2012, 11:37 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,582
Blog Entries: 2

Rep: Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037
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.
 
Old 05-05-2012, 11:38 AM   #5
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,658

Rep: Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252
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.
 
Old 05-05-2012, 12:23 PM   #6
jefro
Guru
 
Registered: Mar 2008
Posts: 11,419

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

Makes a expect script as easy as can be.
 
Old 05-05-2012, 12:23 PM   #7
ashu_ky
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-05-2012, 12:33 PM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,582
Blog Entries: 2

Rep: Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037
As said already before, use key-based authentication and you don't need to type in a password.
 
Old 05-05-2012, 12:52 PM   #9
ashu_ky
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
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.
 
Old 05-05-2012, 01:08 PM   #10
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,658

Rep: Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252
you do not need root account if ssh installed.
you only need to configure the user you want to use.
 
Old 05-05-2012, 01:11 PM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,582
Blog Entries: 2

Rep: Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037
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.
 
  


Reply

Tags
script, scripting, ssh, telnet, unix


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to automatically login through ssh and create user Sayan Acharjee Linux - General 10 10-21-2010 01:51 AM
How can I create a remote login script w/ options jsullivan44 Programming 1 08-11-2010 10:40 AM
Create a Linix script that prints out all failed login attempts. nick_astn Linux - Newbie 3 08-13-2008 05:56 PM
ssh or telent auto login prashant_1012 Programming 1 11-22-2005 01:12 PM
Create a login script? jedimastermopar *BSD 4 08-02-2004 08:07 AM


All times are GMT -5. The time now is 07:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration