Re: [CentOS] automated stopserver shutdown?

2014-11-18 Thread Hadi Motamedi
 Please google for passwordless SSH authentication (Which many list
 members most likely will disapprove)


 Request you to try something and post queries when it fails completely
 with error message etc.

 http://www.firedaemon.com/blog/passwordless-root-ssh-public-key-authentication-on-centos-6

 http://www.itzgeek.com/how-tos/linux/centos-how-tos/password-less-login-ssh-centos-6-rhel-6.html#axzz3JKqkl74g

 You have been posting queries in this in other lists often without
 doing your homework.

 and post a thanks if any solution works out for you as all the members
 here are voluntary contributors whi are sharing their valuable time
 and experience.

Thank you very much for your help. It solved my problem.
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-17 Thread Alexander Dalloz

Am 17.11.2014 um 06:56 schrieb Hadi Motamedi:

Dear All
In an environment , I have 20 centos servers running together . For
shutting them down , I need to issue the followings on each of the
servers :
#./stopServer
#init 0
This is cumbersome to try to issue these on huge amount of servers to
keep them safely going shutdown. Can you please let me know how can I
automate it and say let just one server send stop processes and
shutdown commands to the other ones and then goes shutdown himself?
Thank you


Try out ansible.

Using it you can automate many more tasks distributed over your server 
environment through very simple configurations. It is very flexible and 
powerful.


Alexander


___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-17 Thread Hadi Motamedi

 Try cssh



Thank you for your help. Is there any way to automate an ssh session
on them say write a script to automatically ssh to them via root
password and pass a command to them?
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-17 Thread Rajagopal Swaminathan
Greetings,

On Mon, Nov 17, 2014 at 2:33 PM, Hadi Motamedi motamed...@gmail.com wrote:

 Try cssh



 Thank you for your help. Is there any way to automate an ssh session
 on them say write a script to automatically ssh to them via root
 password and pass a command to them?

Please google for passwordless SSH authentication (Which many list
members most likely will disapprove)


Request you to try something and post queries when it fails completely
with error message etc.

http://www.firedaemon.com/blog/passwordless-root-ssh-public-key-authentication-on-centos-6

http://www.itzgeek.com/how-tos/linux/centos-how-tos/password-less-login-ssh-centos-6-rhel-6.html#axzz3JKqkl74g

You have been posting queries in this in other lists often without
doing your homework.

and post a thanks if any solution works out for you as all the members
here are voluntary contributors whi are sharing their valuable time
and experience.

-- 
Regards,

Rajagopal
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-17 Thread James B. Byrne
On Mon, November 17, 2014 01:17, Hadi Motamedi wrote:
 A simple script which loops though a text file that lists the hostname /
 username / password for the login and then runs the shutdown - h now
 command? Though, I would be uneasy with listing root passwords in a
 random text file.


 Thank you for your help . So how to open a session with another server
 to login with root password and issue a command on it ?



I do not believe that, on reflection, you really would want to do that.  An
alternative approach is to use ssh-keygen to create a key pair for root on the
control host and then add that public key to the authorized_keys file inside
/root/.ssh on each of the target hosts.  So, something like this:

On control host as root user:

ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/path to userid home
directory/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /path to userid home
directory/.ssh/id_rsa.
Your public key has been saved in /path to userid home
directory/.ssh/id_rsa.pub.
The key fingerprint is:
1c:6c:91:76:64:83:a5:32:4e:ac:df:28:ed:cb:9a:dd userid@hostname

That will give you the following files in /root/.ssh

 ll .ssh
total 28
-rw-r--r--. 1 root root 4619 Nov 17  2014 authorized_keys
-rw---. 1 root root 3239 Nov 17  2014 id_rsa
-rw-r--r--. 1 root root  756 Nov 17  2014 id_rsa.pub


Now login to each of your target hosts as root and transfer
/root/.ssh/id_rsa.pub from the control host and append () it to
/root/.ssh/authorized_keys on the target host.  If the .ssh directory does not
already exist on the target host then you should first create the necessary
files by running ssh-keygen on the target (otherwise you need consider whether
or not selinux is enforced or not? is the mode set correctly? yada, yada).

Once you have setup the target hosts for ssh and have added the control host's
public key to .ssh/authorized_keys then you should be able to ssh into each
from the control host without having to provide a password.

You will however need to add each remote host's identity
(/etc/ssh/ssh_host_rsa_key.pub) to your own /root/.ssh/known_hosts file the
first time that you connect.  This can be automatically created and maintained
by the ssh client so long as the remote host's ssh identity is not
subsequently changed.  If you have previously ssh'ed into the remote hosts
than this will already have been done.

Once the connections have been set up between the control host and all of the
target hosts then you should be a able to do this (mind the -t option to ssh):

for host in \
  long_host_name.domain.tld \
  targethost{01,02,03,04,05,06}.domain.tld \
  othername{x,y,z}.domain.tld \
  yet_another_very_long_host_name.domain.tld \
  192.168.0.2{1,5,7,8,9} ;
  do ssh -t $host 'echo -e \n\n$HOSTNAME\n ; /root/stopServer ; init 0';
  done

Personally, I would use a separate account for this and add that account to
the /etc/sudoers file on each of the targets:
shutdown_userid  NOPASSWD: localhost=/sbin/init 0
shutdown_userid  NOPASSWD: localhost=/sbin/shutdown -h now
shutdown_userid  NOPASSWD: localhost=/root/stopServer

The ssh-keygen / authorized_hosts setup would then need to be done in that
account's home directory on each target rather than root's. Then use 'sudo
/root/stopServer ; sudo init 0' to run the shutdown scripts.

I also would use 'shutdown -h now' instead of 'init 0'

-- 
***  E-Mail is NOT a SECURE channel  ***
James B. Byrnemailto:byrn...@harte-lyne.ca
Harte  Lyne Limited  http://www.harte-lyne.ca
9 Brockley Drive  vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada  L8E 3C3


___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] automated stopserver shutdown?

2014-11-16 Thread Hadi Motamedi
Dear All
In an environment , I have 20 centos servers running together . For
shutting them down , I need to issue the followings on each of the
servers :
#./stopServer
#init 0
This is cumbersome to try to issue these on huge amount of servers to
keep them safely going shutdown. Can you please let me know how can I
automate it and say let just one server send stop processes and
shutdown commands to the other ones and then goes shutdown himself?
Thank you
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-16 Thread Laurent Dumont
A simple script which loops though a text file that lists the hostname / 
username / password for the login and then runs the shutdown - h now 
command? Though, I would be uneasy with listing root passwords in a 
random text file.


On 11/17/2014 12:56 AM, Hadi Motamedi wrote:

Dear All
In an environment , I have 20 centos servers running together . For
shutting them down , I need to issue the followings on each of the
servers :
#./stopServer
#init 0
This is cumbersome to try to issue these on huge amount of servers to
keep them safely going shutdown. Can you please let me know how can I
automate it and say let just one server send stop processes and
shutdown commands to the other ones and then goes shutdown himself?
Thank you
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-16 Thread Hadi Motamedi
 A simple script which loops though a text file that lists the hostname /
 username / password for the login and then runs the shutdown - h now
 command? Though, I would be uneasy with listing root passwords in a
 random text file.


Thank you for your help . So how to open a session with another server
to login with root password and issue a command on it ?
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] automated stopserver shutdown?

2014-11-16 Thread Rajagopal Swaminathan
Greetings,

On Mon, Nov 17, 2014 at 11:47 AM, Hadi Motamedi motamed...@gmail.com wrote:
 A simple script which loops though a text file that lists the hostname /
 username / password for the login and then runs the shutdown - h now
 command? Though, I would be uneasy with listing root passwords in a
 random text file.


 Thank you for your help . So how to open a session with another server
 to login with root password and issue a command on it ?


Try cssh


-- 
Regards,

Rajagopal
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos