Sending password over SSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending password over SSH
# 1  
Old 11-10-2014
Sending password over SSH

Hi guys,

I wrote a script that logs into around 30 nodes via SSH as root.

The issue is that I have to punch in the root password everytime and it is being a hassle.

Is there a way to save the password in a secure way and automate the whole procedure. I do not want to save the password in the script itself as that will be a security risk. The script is :

Code:
#!/bin/bash

for i in `cat nodes.txt`
do
echo $i
ssh root@$i "ps -ef | grep puppet | grep -v grep |awk '{print \$2}' | xargs kill -15 "
done

Sample output:

Code:
user1@server /scripts $ ./killpuppet.sh 
server1
Password:
server2
Password:
server3
Password:
server4
Password:
server5
Password:

# 2  
Old 11-10-2014
Why not use your public keys?
# 3  
Old 11-10-2014
Thank you for the suggestion. But security wise, that's not an option.
# 4  
Old 11-10-2014
Its by far the safest method you know?
Exchanging your keys need to be done only once ( well after it will depend of patches etc...)
This User Gave Thanks to vbe For This Post:
# 5  
Old 11-10-2014
Quote:
Originally Posted by Junaid Subhani
Thank you for the suggestion. But security wise, that's not an option.
Why not?

Because saving passwords is MORE secure?

If you need to automate running commands remotely on another machine, using the key exchange of SSH is by far the most secure method.

Saving a password to be accessed by a script somewhere is just about the least-secure method.

If your security organization won't allow you to use SSH keys, but will allow you to save a password, they're incompetent.
These 2 Users Gave Thanks to achenle For This Post:
# 6  
Old 11-10-2014
I agree with what you've said. It isn't the organization that has asked me to look into other options that SSH keys. Its I who wants to look at other possible ways.

But I have to agree to use SSH is something I will work on now. Thank you for the help.
# 7  
Old 11-10-2014
Well using .rhosts files might be safer than copying passwords around...
This User Gave Thanks to vbe For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

1 Script Not Sending Password - Other Scripts OK

I am building FTP Script on my Bluehost VPS Server. I have several and all work great except this one.... I think there are two issues .. One with the command and One with "$" in the password. #!/bin/sh HOST=invtransfer@52.44.151.220 USER=invtransfer PASSWORD=XXX$XXX - $ is real in... (3 Replies)
Discussion started by: Wrjames2
3 Replies

2. Red Hat

SSH password less setup asking for password

Hello Experts, when I am trying to connect my target server through sftp after creating ssh password less setup, it is asking for passowrd to connect. to setup this I followed below process: -->generated keys by executing the command "ssh-keygen -t rsa" -->this created my .ssh directory... (9 Replies)
Discussion started by: Devipriya Ch
9 Replies

3. Shell Programming and Scripting

ssh sending local variable to remote system

I am running a useradd script, which works locally but I want to take some of that local information and send it to a remote system, ssh keys are set up between the two systems. I am attaching the script, look at the section titled "Sending information to FTP2" Removed attachment, added... (0 Replies)
Discussion started by: slufoot80
0 Replies

4. Homework & Coursework Questions

Sending encrypted messages (ssh or scp)

1. we are a group a students and we need a help for sending encrypted messages with unix (ssh or scp) 2. we tried to use ssh and scp protocol but we didn't manage to send the message because we don't know the correct syntax of the command and we are asked a password and we don't know which is... (1 Reply)
Discussion started by: supervavul
1 Replies

5. Shell Programming and Scripting

Expect Script sending password with $ and symbols

All, I am trying to use expect to send SFTP password because I am unable to share a key with the vendor. They gave me a password that uses some symbols in it like $ and ! When i try to use the send command in expect it thinks the $ is a variable. Is there anyway to have it send the... (2 Replies)
Discussion started by: markdjones82
2 Replies

6. Solaris

Pam Module sending a cannot get password enry after certain period in /var/adm/messag

Pam Module sending a cannot get password enry after certain period in /var/adm/message. pam_login_limit(auth): Cannot get Password entry for user 'dbsnmp' What is dbsnmp? Also if account is locked does pam module checks for this locked account at regular interval and keeps on posting... (2 Replies)
Discussion started by: student2009
2 Replies

7. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

8. Shell Programming and Scripting

Sending ssh password in a script

Is there any way to send password in a sh script, to establish a ssh connection with the remote server, without having shared the public key? The command I'm currently using is in my script is !#/bin/sh ... ssh -l user remotehost "ls -l" I have shared the public key of the local... (3 Replies)
Discussion started by: farahzaiba
3 Replies

9. Windows & DOS: Issues & Discussions

ssh: sending password from windows client

Hi. My workstation is Windows. I use putty to connect to unix servers. The problem is that i'm doing it many times a day and each time i need to supply password. I have no control on ssh configuration on servers, because of account restrictions. So i can't use key authentication, how is suggested... (4 Replies)
Discussion started by: kukuruku
4 Replies

10. Cybersecurity

Sending a message to a user when password will be expired

Hi, Does anyone have a script (for AIX) that sends a message to a user that his password will be expired within 5 days for ex. Thanks (1 Reply)
Discussion started by: Diederd
1 Replies
Login or Register to Ask a Question