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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-23-2003, 12:06 PM
|
#1
|
|
LQ Newbie
Registered: Aug 2003
Posts: 8
Rep:
|
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?
|
|
|
|
09-23-2003, 03:13 PM
|
#2
|
|
LQ Newbie
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13
Rep:
|
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!
|
|
|
|
09-23-2003, 03:44 PM
|
#3
|
|
LQ Newbie
Registered: Aug 2003
Posts: 8
Original Poster
Rep:
|
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?
|
|
|
|
09-23-2003, 03:50 PM
|
#4
|
|
LQ Newbie
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13
Rep:
|
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
|
|
|
|
09-24-2003, 10:16 AM
|
#5
|
|
LQ Newbie
Registered: Aug 2003
Posts: 8
Original Poster
Rep:
|
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
|
|
|
|
09-24-2003, 10:30 AM
|
#6
|
|
LQ Newbie
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:28 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|