How to make this command work wihtout password prompt?


 
Thread Tools Search this Thread
Operating Systems Linux How to make this command work wihtout password prompt?
# 1  
Old 06-27-2017
Wrench How to make this command work wihtout password prompt?

Hi,

I am trying to run this command to connect to each server without being prompted for the password. How can I do this in Linux redhat 7.2:

Code:
 
 for HOST in $VIPS; do
su - Myadminid -c "ssh -o ConnectTimeout=10 $HOST 'date; hostname; pkill -9 -f -u Myadminid xx00 ; ps -ef |grep Myadminid'" 
 done

Please help. when I use echo 'password' | it get stty errors ! Thanks
# 2  
Old 06-27-2017
Did you consider ssh's "public key authentication"?
# 3  
Old 06-27-2017
I need it done without the ssh keys. I have the ssh keys in place. However this script will be use by an HA software that will call under root and it must su to that id so it can run the commands. The ssh keys in this case do not work. I must pass it the password of my id within the command. How do I do that? Thanks
# 4  
Old 06-28-2017
ssh keys will work if you use "ssh -x adminuser@yourhostname..." instead of "su - adminuser -c ..."
But maybe sudo is more appropriate
Code:
man  sudo
man sudoers

# 5  
Old 06-28-2017
also, kill -9 is never appropriate.
# 6  
Old 06-28-2017
Does root have to have anything setup for myid when it runs the the ssh -x myid@hostname so it will not required the password ? or will it just automatically pickup my id ssh keys located on my id .ssh ?
# 7  
Old 06-28-2017
Quote:
Originally Posted by Corona688
also, kill -9 is never appropriate.
And
Code:
ps -ef |grep Myadminid

should better become
Code:
ps -fu Myadminid

or
Code:
pgrep -lfu Myadminid

---------- Post updated at 13:03 ---------- Previous update was at 12:59 ----------

Quote:
Originally Posted by mrn6430
Does root have to have anything setup for myid when it runs the the ssh -x myid@hostname so it will not required the password ? or will it just automatically pickup my id ssh keys located on my id .ssh ?
Normally not.
myid needs to have the public key from the calling user installed in the file ~myid/.ssh/authorized_keys2 or ~myid/.ssh/authorized_keys (depending on the sshd version; file permissions should be 600, unreadable for others).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Kshrc custom prompt will not work

So Yesterday I switched from Solus Linux to Fedora Linux 30, but I forgot to backup some of my dotfiles including kshrc. I am fairly new to Korn shell and do not know it well, but through memory I was able to at least get this. I did use code from several different source to recreate it. The only... (13 Replies)
Discussion started by: zoomer
13 Replies

2. AIX

Sudo command prompt for a password

in the /etc/sudoer file this line was added: wtolentino ALL=(ORACLE) NOPASSWD: /bin/chmod when i tried to run this command sudo -u oracle /bin/chmod 775 /appshared/applications/lpa/executables/chrpt001.rep it prompts me for a password for example: $ pwd /appshared/applications/lpa... (2 Replies)
Discussion started by: wtolentino
2 Replies

3. Red Hat

RHEL6 customizing prompt do not work

Hi, I'm trying to customize the ksh prompt for users on a RHEL 6.6 system for having user@host pwd : $ and user@host pwd # in red color for root. I think it's possible but i do not even succeded for a non root user : I added in my ~/.kshrc : PS1="Hello : " and it works but when i... (4 Replies)
Discussion started by: Fundix
4 Replies

4. Solaris

Not getting command prompt after entering the login password

Hi All, I am not able to get the command prompt after entering the login password on solaris server Only access is through console. Server type : sun4u sparc SUNW,Netra-T12 bsnl-north-in > ssh 10.147.17.207 jtoin Connecting to 10.147.17.207 as user jtoin Password: Last login: Wed Mar 5... (1 Reply)
Discussion started by: sandeep_kmehra
1 Replies

5. Shell Programming and Scripting

Color prompt with file numbers does not work anymore

I have used this color prompt on my servers for long time, in file ~\.bashrc Black="\" Dark="\" Blue="\" LBlue="\" Green="\" LGreen="\" Cyan="\" LCyan="\" Red="\" LRed="\" Purple="\" LPurple="\" Brown="\" Yellow="\" LGray="\" White="\" Reset="\" PS1="$Yellow\u@\h $LBlue\w... (4 Replies)
Discussion started by: Jotne
4 Replies

6. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

7. UNIX for Advanced & Expert Users

su command without password prompt to non-root account

Hello. I searched the internet for answers and don't seem to find any for about a day now. My problem. I want to su to a non-root account non-interactively, e.g. if I want to temporarily become prdusr, I want to su prdusr without keying prdusr's password every time. What I want is... (10 Replies)
Discussion started by: royale-sojin
10 Replies

8. UNIX for Dummies Questions & Answers

Getting current work directory in Command Prompt

How to get the current working directory as part of the command prompt? Every time I chage the folder, my command prompt path shoud change. I am using Korn Shell. Any help is greatly appreciated. (3 Replies)
Discussion started by: MeganP
3 Replies

9. Shell Programming and Scripting

How to make my command work at all times

hi all, This is a very basic question. I want to make the command work at all times. i'm working on Suse-Linux and "clear" command is used to clear the contents of screen. I want to use only "cls" instead of "clear" command. i tried alias cls=clear , but its working only for a temporary... (3 Replies)
Discussion started by: wxwidgets
3 Replies

10. Shell Programming and Scripting

any way to use SU command without prompt for password

Hi, First i want to tell you i am not a administrator and everytime to run a sqlscritpt i have to login as SU in a particular account to connect to sqlplus.. I want to write a script which can make me free by doin this .. since i am having the permission for SU i want to know if i can SUDO... (7 Replies)
Discussion started by: myelvis
7 Replies
Login or Register to Ask a Question