LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 05-07-2002, 04:53 PM   #1
lethe
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Rep: Reputation: 0
telnet login via shell script


is it possible for me to have a shell script log me in to a telnet session? i have in mind something along the lines of

% telnet host < script, where the first two lines of script will be username and pass followed by a list of commands to execute on the remote host.

this doesn t work as written, because telnet expects the login and pass to come from standard in, and won t seem to let me redirect.

any thoughts?
 
Old 05-07-2002, 05:05 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
hmm, yes it is possible, but it is A VERY BAD THING TO DO AND SHOULD BE AVOIDED AT ALL COSTS.

but if you really insist, i think you go something like:

( echo $USER; sleep 1; echo $PASS; sleep 1; echo exit ) | telnet abc.com
 
Old 05-10-2002, 04:54 AM   #3
lethe
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Original Poster
Rep: Reputation: 0
why is it bad? i guess because people can read your password. if it is only in your head then no one can steal it, right?
 
Old 05-11-2002, 07:58 AM   #4
growler
Member
 
Registered: Apr 2002
Posts: 84

Rep: Reputation: 15
Quote:
Originally posted by lethe
why is it bad? i guess because people can read your password. if it is only in your head then no one can steal it, right?
ding! ding! that's it!

two issues: 1st, telnet sends all info as clear text, meaning someone using a packet sniffer can find out all the commands you typed using telnet - username, password, commands you executed, output of those commands, etc.; 2nd, your idea requires you to store your password in a file somewhere on your disk - also bad!

use ssh rather than telnet. it uses an encrypted data-stream.

you can also configure ssh to auto-magically accept the connection (passwordless logons), without sending the password, by copying your local authentication keys to your remote keyfile. this would be useful for your script idea.

unfortunately, that explanation would take a few pages, and I'd basically be plagiarizing the ssh chapter from Building Linux VPNs. Great book!
 
Old 05-11-2002, 11:15 PM   #5
lethe
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Original Poster
Rep: Reputation: 0
can you pipe commands to ssh? when i try it, it just exits, saying that stdin is not a terminal.
 
Old 05-12-2002, 05:41 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
no, because it is again.. and EXTREMELY DUMB THING TO DO! ssh designers had the sense to not let it ever happen in the first place. security should always come first.
 
Old 05-12-2002, 11:37 AM   #7
Hano
Member
 
Registered: Sep 2001
Location: Venezuela, Caracas
Distribution: RedHat 9.0
Posts: 196

Rep: Reputation: 30
i understand that ssh doesn't allow to send the USER and PASS piped for security reasons, but, why it doesn't allow you to pipe commands directly? for now, the only way to do that that i'd found is:

set a passwordless login

then call
ssh -x host.org <command>

but this way has the disadvantage of closing the connection after finishing executing the <command> . There is no way to pipe commands from a script without having to close and reopen ssh for every new command??


Thanks in advance

Hano
 
Old 05-13-2002, 04:30 AM   #8
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
Can't you place the script you want to run on the server and then do something like:

ssh -f hostname scriptname
 
Old 05-13-2002, 10:31 AM   #9
Hano
Member
 
Registered: Sep 2001
Location: Venezuela, Caracas
Distribution: RedHat 9.0
Posts: 196

Rep: Reputation: 30
yes, you can! but it closes the ssh connection after finishing. I would prefer a stream where you can pipe commands to the ssh without closing it.


Hano
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can we telnet the system using shell script suchi_s Programming 18 02-18-2005 03:43 PM
telnet windows m/c from unix shell script ann124 Programming 1 11-10-2004 02:26 PM
shell script to autologin into a telnet session eastj1974 Linux - General 1 11-17-2003 08:58 PM
PB launching shell-script with telnet Naurore LinuxQuestions.org Member Success Stories 1 08-04-2003 08:42 AM
PB launching shell-script with telnet Naurore Linux - Newbie 1 08-04-2003 05:45 AM


All times are GMT -5. The time now is 03:13 AM.

Main Menu
Advertisement
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