Need to pass credentials in one Go


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Need to pass credentials in one Go
# 1  
Old 07-22-2013
Need to pass credentials in one Go

Hi,

We usually switch user using the below command.
Code:
 
sudo su - user1

It then prompts for the password which we feed in.

I wish to pass both the username and the password in one go thus eliminating the prompt for the password.

I am using java standalone to connect to unix using java technology JSCH.

Any workaround will also do.

Can you please help ?
# 2  
Old 07-22-2013
In the sudoers file you have to add the entry as NOPASSWD for for the id .May be ur admin can do it.
# 3  
Old 07-22-2013
Bug

Quote:
Originally Posted by millan
In the sudoers file you have to add the entry as NOPASSWD for for the id .May be ur admin can do it.
Two questions ..

1. If i can ask the Admin to do so then how will i pass the password? can you share the command format as example?

2. If my Admin does not implement the above because it goes against company policy, then what is the solution to this problem ?

---------- Post updated at 05:39 AM ---------- Previous update was at 03:44 AM ----------

Quote:
Originally Posted by millan
In the sudoers file you have to add the entry as NOPASSWD for for the id .May be ur admin can do it.
Can a script help here ?

I can invoke a unix shell script from my java code.

Is it possible to pass the user id and the password to the script which used switch user? If so, please help me code the script.
# 4  
Old 07-22-2013
Quote:
Originally Posted by mohtashims
Can a script help here ?
su, sudo, and other login systems are designed to prevent being scripted.
# 5  
Old 07-22-2013
The response from millan will remove the password prompt, so there is no need to supply it.

It's the best solution if you trust your users not to leave their screen open.




Robin
# 6  
Old 07-22-2013
Tools

What is the sudoers file that Millan stated ?

Is it the same for all users ?

I thought I could save the username and password in a file which could be provided to sudo command. Will that work ?

Are we exhausted with no solution apart from Millan's ?
# 7  
Old 07-22-2013
Quote:
Originally Posted by mohtashims
I thought I could save the username and password in a file which could be provided to sudo command. Will that work ?
To repeat:
Quote:
Originally Posted by Corona688
su, sudo, and other login systems are designed to prevent being scripted.
This is a security measure, because stored plaintext passwords are an extremely bad idea.

They insist on talking to a human, and the way to do that is to insist on talking to a terminal. Not pipes, not files, just terminals.

You can fake a terminal with the expect language if you absolutely must, but this is a last resort.

Setting nopasswd in sudoers is a better idea. Even better if you can restrict it to one exact thing.

sudoers is sudo's config file, which you edit with the visudo command.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Hide and retrieve database credentials

Hi Everyone, I am new to shell scripting and I have a requirement to fire a sql statement to Oracle database and create a out file in Unix server. This will be plugged in to Autosys as a batch job. I have the database credentials saved in a configuration file in the below format. ... (7 Replies)
Discussion started by: Pradeep_Raj
7 Replies

2. AIX

Passing user/pass credentials to automountd map file.

How could I pass credentials to the automountd daemon through it's map files? Tried credentials=/some/file.txt - Didn't work. Tried SHARE.domain.com/user/pass/SHARE_NAME in map file - Didn't work Tried user=USER,pass=PASS - Didn't work. I can see the mounts created but when I access them... (4 Replies)
Discussion started by: Devyn
4 Replies

3. Shell Programming and Scripting

Logging into device with other set of credentials

If I run the below code... it will login into the router and then changes to privilege mode and then stores the running configuration information to an array. In this program, I have included the username and password . In case the username and password is wrong.. it will re login for 2 times... (0 Replies)
Discussion started by: scriptscript
0 Replies

4. Shell Programming and Scripting

Wget/curl credentials validation

Experts, I login to a 3rd party and pull some valuable information with my credentials. I pass my credentials via --post-data in wget. Now my Account is locked. I want my wget to alert that the Account is locked. How can i achieve this. My idea is, get the Source page html from the... (2 Replies)
Discussion started by: sathyaonnuix
2 Replies

5. Shell Programming and Scripting

perl script to open an executable and pass the user credentials

Is it possible to open an executable file and pass user credentials through the perl script. If yes Please do share the CPAN module names and the way to access the executable file. For eg. I want to open the IBM LOTUS Sametime through my perl code and pass the user credentials like... (1 Reply)
Discussion started by: giridhar276
1 Replies

6. Web Development

How to pass user credentials between apps on the same server?

I have a wordpress site that authenticates against a local ldap database for users to login. On the same server and domain I have subsonic installed that also authenticates against the same ldap database. The ldap database is firewalled front the outside wall and the internal LAN. I would like... (3 Replies)
Discussion started by: barrydocks
3 Replies

7. Shell Programming and Scripting

FTP credentials from a config file

Hi, I am using the following syntax to connect to an FTP server and paste the file. Based on the value in the variable $Folder, i want to connect to different folders on the same server. The credential is different to access different folders. How to get the user name and password from a... (3 Replies)
Discussion started by: ashok.k
3 Replies

8. Shell Programming and Scripting

Hide DB Credentials in unix

Hi, I my unix we have one file that contains all the database credentials. we are calling that file while connecting databse. I need to hide that file....other user should not view that file. How to do this. Please suggest me apart from permisstion(chmod) level suggestion. Regards,... (3 Replies)
Discussion started by: rsivasan
3 Replies

9. AIX

Telnet Credentials

Dears i am going to write a shell script to do some administration jobs and automate them , but i need to access remote servers through telnet so my question is how to pass the required credentials to telnet through shell script or can i use a file and redirect the standard input to be from that... (3 Replies)
Discussion started by: TheEngineer
3 Replies

10. UNIX for Dummies Questions & Answers

Ldap : Invalid credentials

Hi All, :) I have configure openldap but when I test this its show me a massage that "Invalid Creedientials". I search for the slove at Google, Yahoo but I did not find any solution. Plz help me. :cool: (3 Replies)
Discussion started by: Sudipta Biswas
3 Replies
Login or Register to Ask a Question