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
# 15  
Old 11-14-2011
You do realize that makes your password visible in plaintext to everyone and anything on the system while the command is running, yes? There's a reason they work so hard to discourage you from passing recoverable passwords around.
# 16  
Old 11-15-2011
well thank you to worry about my password.

It won't be visible because i will type it as the script begin to run.
This script will connect more than 100 machines and i don't want to type it each time a ssh command will run.

This is a very important script for me and i'm sure there's a solution to enter the password with the "ssh -t"

Christian
# 17  
Old 11-15-2011
Quote:
Originally Posted by Nicol
well thank you to worry about my password.

It won't be visible because i will type it as the script begin to run.
This script will connect more than 100 machines and i don't want to type it each time a ssh command will run.

This is a very important script for me and i'm sure there's a solution to enter the password with the "ssh -t"

Christian
Hi Nicol,

There is no parameter for you to input password to ssh command. There is only way to using ssh command without password, It's using public key authentication.

Please make sure that OpenSSH was installed on your system, follow below steps:


1. On the client run the following commands:

Quote:
$ mkdir -p $HOME/.ssh
$ chmod 0700 $HOME/.ssh
$ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ''
This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key). Copy $HOME/.ssh/id_dsa.pub to the server.

2. On the server run the following commands:

Quote:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
$ chmod 0600 $HOME/.ssh/authorized_keys2
Depending on the version of OpenSSH the following commands may also be required:

Quote:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
$ chmod 0600 $HOME/.ssh/authorized_keys
An alternative is to create a link from authorized_keys2 to authorized_keys:

Quote:
$ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys
3. On the client test the results by ssh'ing to the server:

Quote:
Quote:
$ ssh -i $HOME/.ssh/id_dsa server
Good luck to you ! Smilie
# 18  
Old 11-15-2011
thanks for all,

i've done all that and it works in all the cases except the case with the crontab command

With the keys installed i run with success without password :

Code:
ssh myuser@host1  "ls -al /home"

but the same with crontab :

Code:
ssh myuser@host1  "crontab -l"

display the myuser crontab this is normal

if i want to display the newuser crontab , i'm forced to use the following and to entrer the password

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

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

doesn't work !

christian
# 19  
Old 11-15-2011
Why not login as newuser in the first place?

Or why not configure sudo to allow you to su - username without a password for that specific login?

---------- Post updated at 04:58 PM ---------- Previous update was at 04:57 PM ----------

Quote:
Originally Posted by Nicol
well thank you to worry about my password.

It won't be visible because i will type it as the script begin to run.
It will be visible every time you run 'echo password' to feed it into something, because commandline arguments are visible to anyone on the system.

The bigger the hassle it is for you to do this right, the bigger the danger is when your password does get stolen. If someone gets that, they have the key to hundreds of your servers.
# 20  
Old 11-15-2011
If you have setup your keys for ssh login, then to supply password for sudo, your original approach would work except that you need an extra "-t":

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

# 21  
Old 11-16-2011
hi

Quote:
Why not login as newuser in the first place?
==> because the security doesn't accept it , we are forced to log with names user

Quote:
Or why not configure sudo to allow you to su - username without a password for that specific login?
==> it is , the keys have been created without password , this is the "ssh -t" that force to type password.

i understand all what you are saying but i'm not root admin and i can't modify this policy.

then the following :
Code:
echo password | ssh -t -t myuser@host1  "sudo -u newuser crontab -l"

doesn't work , i have this message :

Quote:
tcgetattr: Not a typewriter
so....what can i do ?
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