Hi,neutronscott
Thanks for your help.
Thus for me to enter the password (password is pass123 for all servers), i just have to add this line right before echo "testing on $server" right?
Just one last questions, will this harm my servers since i have hundreds of servers to be excecuted ?
Last edited by Scott; 04-19-2012 at 09:33 AM..
Reason: Code tags
You may want to look at a Parallel SSH implementation. Also, one cannot script the password prompt. ssh opens the terminal directly. Ideally you'd setup authorized_keys, or use "expect" (TCL script which acts like a terminal). I'm not well read in these things, sorry.
This User Gave Thanks to neutronscott For This Post:
You may want to look at a Parallel SSH implementation. Also, one cannot script the password prompt. ssh opens the terminal directly. Ideally you'd setup authorized_keys, or use "expect" (TCL script which acts like a terminal). I'm not well read in these things, sorry.
copy content of id_rsa.pub of client into authorized_keys of host
sure..
Be aware that using an unquoted heredoc will expand parameters locally. Is why it will expand $server inside single quotes. See difference:
Hi neutronscott, I could not understand the quoting of here-document stuff that you told.
Also, I read the following about here-documents:
All special characters between here-document, such as $, `, *, ... need to be escaped otherwise the code will be evaluated first by the calling shell
\EOF -- this "here-document", escaped version is used to prevent expansion
Escaping or quoting the delimiter for a here-document instructs the shell not to perform parameter expansion, command/variable substitution and arithmetic expansion on the here-document's contents
so my questions are:
a) what is the difference between \EOF and 'EOF'?
b) what do you mean by expanding locally? As per your example, when I issue ssh command it would be logged into the remote machine after successful password entry. So in that case, it is not in local anymore. So it should have printed the server name right, as I have the quoted the here-document parameter (i.e) 'EOF'?
Also, if you see the following code:
this will print the variable's value, since it has been escaped. So how it is different from quoting/unquoting of here-doc parameter? Kindly clarify me
Last edited by royalibrahim; 04-19-2012 at 10:49 AM..
as in, $VARIABLE gets substituted before the text gets fed into ssh.
If you're ever in doubt about what will get fed raw into ssh, try
To see what the raw, uninterpreted contents of what is received on the other end actually are.
Quote:
As per your example, when I issue ssh command it would be logged into the remote machine after successful password entry. So in that case, it is not in local anymore.
It hardly matters whether it's local "anymore". ssh is not an escape-hatch or shell extension by which your shell script gets funneled raw into something remotely, ssh is just a program like anything else; your own shell must interpret the entire statement first to run it at all.
If you don't want it substituting things which any shell would think deserves substituting, you must prevent it from doing so by various means -- quoting, escaping, the right kind of here-documents, and the like.
Last edited by Corona688; 04-19-2012 at 11:04 AM..
Hi,
I am trying to complete my bash script in order to find which SSH servers on LAN are still active with the ssh keys, but i am frozen at this step:
#!/bin/bash
# LAN SSH KEYS DISCOVERY SCRIPT
</etc/passwd \
grep /bin/bash |
cut -d: -f6 |
sudo xargs -i -- sh -c '
&& cat... (11 Replies)
Hi,
I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not...
I have .sh script like below and i have servers.txt contains all the list of servers
#/bin/bash
for host in $(cat... (3 Replies)
Dear All,
I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
I have write a script which contains
ssh -p 12345 dcplatform@10.125.42.50
ssh 127.0.0.1 -p 5555 "$CMD"
ssh root@$GUEST_IP "$CMD"
before I use public key, it works well, now I want to change to "expect", BUT I don't want to change above code and "parameter position"
I can post a... (1 Reply)
Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below.
I am on a solaris server btw.
Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose.
... (2 Replies)
Hello;
Is it possible to run glance over ssh in batch mode ??
Similar to running " top -f " command over ssh..
Need to get glance output for specific pids
Thnx very much (5 Replies)
Hi,
I am really struggling to finish of a script I have been assigned.
The script's purpose is to log on to each server defined in an array, determine the Web Server version, and list the directory beneath the installation directory. In my case, this installation directory is almost always... (6 Replies)
Hi all
I try to execute SSH commands on several hosts in a while-loop.
There seems to be a problem with file-handle, first cycle works correct but no other one will follow due to the while condition is false even that there are many more host entries (lines) in all_hosts.dat.
... (3 Replies)
Team,
I am trying to do ssh batch as root. I have ssh set-up to do work w/o requiring password/uid on remotes.
The problem is I need to submit batch work to remote systems, and NOT have my terminal program.sh lock/wait for the response from remote. This is so I can submit batch work to other... (2 Replies)