LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 09-23-2003, 12:06 PM   #1
Alek
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Rep: Reputation: 0
Question Ssh or logging from shell script


1.Can I ssh and give the password in a shell script so the login will be automatic without user intervention of typing the pass?
I don't want to copy my public key to the host and enable automatic login in that way. I just want to know if it is possible to have the pass hardcoded in a script?

2.Can I do the same using login and giving password in the script?
 
Old 09-23-2003, 03:13 PM   #2
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
You may want to look into "Expect". I would strongly suggest not hardcoding the password and feeding it into your script you are far less secure that way than if you generated ssh keys.
You may want to look into ssh-keygen. Do the manpage on it. ssh is safe and encrypted, if you set up keys on local and remote machines and run your scripts via ssh commands it works pretty good, you are not bad off if you maintain script file permissions and passwords securely, the user password would have to be compromised before any any sshing could be done....and you don't have passwords written down!
 
Old 09-23-2003, 03:44 PM   #3
Alek
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Original Poster
Rep: Reputation: 0
Question Not satisfied

Imagine that you are the user on one linux box and than you want to log on in the same linux box as root.
You can write: login root
And then it prompts you for the password
you type the pass and you are logged in.

I want this proces to be writen in the script, with hardoced password and don't carrying for the security so far.

Do you have any idea how should I write the script?
 
Old 09-23-2003, 03:50 PM   #4
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
you can ssh -l (that is a lower case L) <username>
That will ssh as the user specified with the -l command.
That should fix you up if that is what you are wanting to do.

Do you want to logon as a user or do you want to "switch user" ie.. su - root. This will switch to the root user..it will prompt for password. be careful with the su - root, becuase you will need to log off as the root user when you are done, script a CTRL-D and it will do it
 
Old 09-24-2003, 10:16 AM   #5
Alek
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Original Poster
Rep: Reputation: 0
Question

Please try to answer me if you realy know the answer of question.
I'll try again:

I'm user A on one linux machine. On the same machine I want to switch the user and become user B. In order to do that I have to do:
1.login B
2. It will prompt me for the pass.
3.I will give the pass and I'm now shitched to user B.

I want to write that in a shell script, with written password inside so I can switch the users without a human intervention for typing the password. I don't mind that this is not secure I just want to know if this is possible.

Thanks
 
Old 09-24-2003, 10:30 AM   #6
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
OK for clarity sake...you can write a script to "su" (switch user) and yes it will prompt for password unless you are root, then it will not. You will need to use a tool called expect as mentioned prior. I have provided you a link. http://expect.nist.gov/ You will need to install it on you box(s). Read thru the expect info and that should get you straight.


Hope this clears the issue.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cgi shell script: ssh not working kitmui Programming 2 04-21-2010 02:46 PM
executing a script when logging via ssh rubby1 Linux - General 8 10-06-2005 03:12 PM
Shell Script with ssh & scp ErikJohnson Linux - Software 3 03-11-2004 04:53 PM
Shell Script with ssh & scp ErikJohnson Linux - Networking 1 03-11-2004 04:14 PM
shell script for logging threadhead Linux - General 8 12-27-2002 03:59 PM


All times are GMT -5. The time now is 08:28 AM.

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