Script that automatically issue "yes" and press enter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script that automatically issue "yes" and press enter
# 1  
Old 02-15-2017
Script that automatically issue "yes" and press enter

Team,
Got a thousand servers. I created a script to say hello on every server. But is there a script or whatever that will issue a yes on every key checking.

Code:
for i in `cat myserverlist`
do
echo $i
ssh-copy-id $i
done




The authenticity of host 'server1 (162.162.0.10)' can't be established.
RSA key fingerprint is 1:29:3b:48:d6:e2:h8:18:21:56:4d:5abf.
Are you sure you want to continue connecting (yes/no

# 2  
Old 02-15-2017
You can try the command yes, however another way would be to change your ssh command to automatically accept the fingerprint. This has the drawback that you trust everything you connect to and you have to decide if this is okay.

You would also have to share your public SSH key to each & every target, else you will be prompted for your password for each & every one.

A few more questions though:-
  • What is in the script ssh-copy-id?
  • What is the OS & version or the client (where you run your script) and the servers you want to connect to? The output from uname -a pasted in CODE tags would be great.



Robin
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 02-15-2017
the ssh-copy-id is a command will copy your ssh keys from the server that you have the private key and public key. it will create authorized_keys as well and will change the permission. the os version is rhel 6.
# 4  
Old 02-15-2017
Okay, I've not used that before (you learn something new every day Smilie)

How will you authenticate to each server to allow it to install your public SSH key? You will probably have to provide a password, after all you wouldn't want just anyone connecting and setting themselves up with a public key to login as root now, would you?

That may prove a bigger headache than responding to the prompts. Is there a privileged account that is already able to connect to each server? You should then be able to force out the new public key (making sure you get the permissions correct) through that.

Sadly, hindsight is a wonderful thing.


Robin
# 5  
Old 02-15-2017
Unfortunately no. Smilie that is why i create a for loop statement then type yes on every server. its a like a handshake
# 6  
Old 02-15-2017
"interactive password authentication" means "password typed by a human being in realtime authentication" and no substitutes for human are acceptable to ssh. You'd have to trick it with a brute-forcing language like expect.
# 7  
Old 02-15-2017
Some ssh clients support the StrictHostKeyChecking option, I don't have RHEL 6 available here to try it out, but you could give this a go:

Code:
ssh-copy-id $i -o StrictHostKeyChecking=no

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Syntax error near unexpected token `"Hit <ENTER> to continue:"'

the below code will search attr string inside makefile under the modelno on given path. echo "Enter model no for searching string inside makefile" read inputs2 #find /pools/home_unix/sapte/work/models/model/$inputs2 -name "makefile" | xargs grep "attr" \; #;;I am getting below error.... (7 Replies)
Discussion started by: lathigara
7 Replies

3. Shell Programming and Scripting

""Help Me!""Beginner awk learning issue

Hi All, I have just now started learning awk from the source - Awk - A Tutorial and Introduction - by Bruce Barnett and the bad part is that I am stuck on the very first example for running the awk script. The script is as - #!/bin/sh # Linux users have to change $8 to $9 awk ' BEGIN ... (6 Replies)
Discussion started by: csrohit
6 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Make scipt except from "Y","y" and "yes" to take [Enter] as being "yes"

This is the script: #!/bin/sh if ; then rm -rf /usr/share/WallpaperChanger; fi if ; then rm -rf /usr/bin/wallch; fi; if ; then rm -rf /usr/share/applications/wallch.desktop; fi if ; then rm -rf /usr/share/doc/wallch; fi if ; then rm -rf /usr/share/man/man1/wallch.1.gz; fi echo "Delete... (4 Replies)
Discussion started by: hakermania
4 Replies

6. Shell Programming and Scripting

read -n1 -r -p "Press..." key / produces error in bash shell script

Hello! Sorry, for my not so perfect english! I want to stop bash shell script execution until any key is pressed. This line in a bash shell script read -n1 -r -p "Press any key to continue..." key produces this error When I run this from the command line usera@lynx:~$ read... (4 Replies)
Discussion started by: linuxinho
4 Replies

7. Shell Programming and Scripting

"Write" - how to quit by press enter

I need to make Bash script. It has one parameter - user ID. If this user is online you can write him a message with "write" program, but only one line. After pressing ENTER "write" program should quit. Normally when you run "write" you can write next line after pressing ENTER and you can quit... (0 Replies)
Discussion started by: Eriknem
0 Replies

8. Shell Programming and Scripting

Pressing "Enter/Space bar" using Net::TELNET? in Perl

I'm trying to learn how to get my script to execute the enter button when it telnets into a router and the router displays output but you need to press the space bar or enter button to continue displaying my output of the router. How is this done? (0 Replies)
Discussion started by: xmaverick
0 Replies
Login or Register to Ask a Question