ssh -t answering automatically to the password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh -t answering automatically to the password
# 8  
Old 11-04-2011
hi,

well , if i say i can't ask , that's all i will not ask.

..... sorry i don't understand what you say "vbe" !

Christian
# 9  
Old 11-04-2011
I agree with corona here, if your IT team has like we have aplliances that are after clear passwds on your intranet, you will be in the dog house...
Your only alternative will be since you have the passwd on both system to go for a passwdless connection by exchanging your public keys...

previous: I mean you will be asked twice the passwd how do you bypass that?
# 10  
Old 11-04-2011
Quote:
Originally Posted by Nicol
The "ssh session " is asking the password once.

but i need to answer it automatically with the script because i chain many ssh commands

Christian
It may be possible to reduce the number of ssh calls quite a lot. You can feed entire scripts to the remote side, you don't have to ssh each individual thing. This would also make your script a lot more efficient.
# 11  
Old 11-07-2011
Thanks for your help but definitly i can't ask for a modification of sudoers.

I resume:

i have to ssh more than 100 machines using a:

Code:
ssh -t myuser@host1  "sudo -u newuser crontab -l"

if i don't use
Code:
"ssh -t"

, the "mysuser crontab" is displayed when i want the "newuser crontab"

but with the
Code:
"ssh -t"

i'm forced to type the password

At the beginning of my script i ask for the password because we are 2 or 3 users to do that.

then i want to enter this password as the
Code:
"ssh -t"

will ask it.

i'm sure there is a special way to do that but i'm not too "expert".

regards
Christian
# 12  
Old 11-14-2011
hi,

no ideas anymore?

i've tried to resume the difficulties , i know it's quite special

Christian
# 13  
Old 11-14-2011
Not sure if the version of 'sudo' you're using has this option but there is a -S switch to allow receiving a password from stdin. Although this is an insecure option if someone has access to your script:

Code:
echo -e "password\n" | sudo -S <command>

# 14  
Old 11-14-2011
..but how to try it ?

Code:
echo -e "password\n" | sudo -S ssh -t myuser@host1  "sudo -u newuser crontab -l"

thanks
Christian
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to automatically enter password in a script?

Hi I'm working with AIX 6.1 I would like to ssh to a server without entering password ( to monitor something) but there's no way to do that by authentication keys, so I need to write a script which can ssh to that server without entering password ( no need to hide passsword in the script, just an... (9 Replies)
Discussion started by: bobochacha29
9 Replies

2. Shell Programming and Scripting

In put password automatically to sftp command

Hi all, i have to sftp a file to another server I don't have "expect" or sshpass on my machine its solaris 10, i want to pass password in command line or after doing this sftp user@server how to automatically provide the password as input ( stored in some variable or so) ... (1 Reply)
Discussion started by: zozoo
1 Replies

3. Shell Programming and Scripting

Shell Script to Automatically Read My Password

I have a shell script to run set of commands every week . I dont have a root access on the server but I can run the commands using pbrun cat myscript.sh * * * pbrun command.... each time I run the script , it asks me for my password then it executes fine. ./myscript.sh Password... (7 Replies)
Discussion started by: Sara_84
7 Replies

4. Shell Programming and Scripting

Script to automatically enter a password

I need to retrieve thousands of lines of information from hundreds of nodes. Each node requires a passowrd in order to retrieve the information. Fortunately, the password is the same for each one of them. So I am trying to come up with a script that would allow me to include the password so I can... (0 Replies)
Discussion started by: Ernst
0 Replies

5. UNIX for Dummies Questions & Answers

how to enter hardcoded password automatically

In the script i am passing a command from script which is called from cron. When this command is called from cron the unix prompt asks for password. Can we automatically enter the password when promted(if the password is hardcoded in script)?? Please let me know how to enter the password... (4 Replies)
Discussion started by: abhi_n123
4 Replies

6. Shell Programming and Scripting

Change root password automatically

I need to change root password automatically in some servers all three months. I want to run this process in one of the servers and reply it to the others. The password must be known by the administrator. (3 Replies)
Discussion started by: Alrica
3 Replies

7. Shell Programming and Scripting

automatically create password and expand it to other servers

I´m a new system administrator. I have to create a script to put in crontab to change periodically root password and didtribute it to other servers. I searched the posted threads but I didn't find my answer. I would like to do this using ssh and trusted keys. Can anyone help me? Thanks. Aldina (0 Replies)
Discussion started by: Alrica
0 Replies

8. Shell Programming and Scripting

Is there a way to automatically prepopulate a password field?

I want to know if there is a way that I can right a script that will su to root and prepopulate the password field? (6 Replies)
Discussion started by: chrchcol
6 Replies

9. Shell Programming and Scripting

Perl: answering automatically to install questions

Hi everybody, I have been looking for an answer to this issue both on google and on the forum, but I couldn't find anything. please help me :eek: As part of an automated (in perl) install of Solaris 9, I would like to be able to answer automaticaly to the question the installer asks.... (2 Replies)
Discussion started by: zaap
2 Replies

10. Shell Programming and Scripting

Script to automatically change password.

I want to write a script which will automatically take password sequentially from a file after every 10 days. i.e the passwd command should be executed automatically every 10 days and it should take the input from the password file sequentially. Has any1 got a solution?????????????? (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question