0 Flares Twitter 0 Facebook 0 Filament.io 0 Flares ×
Olá jovens!!!
Tudo bem? Espero que sim…
Olha ai um script bacana para ajudar. Ele faz a troca de chaves entre servidores. 
Fica em “/grid/sshsetup”.

O Portilho escreveu sobre esse script no blog da Nerv [Clique aqui para ver].
O post dele é a base desse post, eu só comentei algumas opções e a saída do script. E também para eu não precisar procurar depois quando eu precisar, resolvi publicar aqui. 

Segue as opções para execução:
./sshUserSetup.sh
                                -user  
                                [ -hosts     “space separated hostlist>” |
                               -hostfile “absolute path of cluster configuration file” ]
[ -advanced ]
[ -verify]
[ -exverify ]
[ -logfile ] 
[-confirm]
[-shared]
[-help]
[-usePassphrase]
[-noPromptPassphrase]

Onde:
-noPromptPassphrase: Valor default. Aqui você diz que não quer usar uma passphrase
-exverify:                   Realiza uma verificação completa após a troca, checando o host
                                      remoto e a conexão local.
-advanced:                 Isso define a conectividade SSH entre os hosts remotos. Significa
                                     que o SSH pode ser usa do para executar comandos em um host
                                     remoto a partir do host atual, por exemplo.
-logfile:                     Gera um arquivo de log
-confirm:                   O normal seria remover permissões de gravação nos hosts remotos
                                     para o diretório home do usuário e o diretório ~/.ssh para “grupo” e
                                     “outros”. O usuário poderia ser explicitamente informados sobre isso.
                                     Caso não queira ser avisado, usa-se o -confirm.

Todas essas informações mais detalhadas você consegue aqui:
   
      [grid@ora11g01 sshsetup]$ ./sshUserSetup.sh -help

Então o comando ficaria assim:

[grid@ora11g01 sshsetup]$ ./sshUserSetup.sh -user grid -hosts “ora11g01 ora11g02” \
                                                        -advanced -exverify -confirm -noPromptPassphrase \
                                                        -logfile “/tmp/teste.txt”

Peguei umas partes mais importantes da saída do script, para ilustrar.

== Verificações dos servidores, se estão respondendo a ping, etc
The output of this script is also logged into /tmp/teste.txt
Hosts are ora11g01 ora11g02
user is grid
Platform:- Linux
Checking if the remote hosts are reachable
PING ora11g01 (192.168.1.190) 56(84) bytes of data.
64 bytes from ora11g01 (192.168.1.190): icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from ora11g01 (192.168.1.190): icmp_seq=2 ttl=64 time=0.028 ms
64 bytes from ora11g01 (192.168.1.190): icmp_seq=3 ttl=64 time=0.030 ms
64 bytes from ora11g01 (192.168.1.190): icmp_seq=4 ttl=64 time=0.029 ms
64 bytes from ora11g01 (192.168.1.190): icmp_seq=5 ttl=64 time=0.028 ms

— ora11g01 ping statistics —
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.028/0.028/0.030/0.005 ms
PING ora11g02 (192.168.1.191) 56(84) bytes of data.
64 bytes from ora11g02 (192.168.1.191): icmp_seq=1 ttl=64 time=0.349 ms
64 bytes from ora11g02 (192.168.1.191): icmp_seq=2 ttl=64 time=0.190 ms
64 bytes from ora11g02 (192.168.1.191): icmp_seq=3 ttl=64 time=0.300 ms
64 bytes from ora11g02 (192.168.1.191): icmp_seq=4 ttl=64 time=0.265 ms
64 bytes from ora11g02 (192.168.1.191): icmp_seq=5 ttl=64 time=0.239 ms
— ora11g02 ping statistics —
5 packets transmitted, 5 received, 0% packet loss, time 4000ms
rtt min/avg/max/mdev = 0.190/0.268/0.349/0.056 ms
Remote host reachability check succeeded.
The following hosts are reachable: ora11g01 ora11g02.
The following hosts are not reachable: .
All hosts are reachable. Proceeding further…
firsthost ora11g01
numhosts 2

== Aqui ele pede a senha do usuário 
— Nó 1
The user may be prompted for a password here since the script would be running SSH on host ora11g01.
Warning: Permanently added ‘ora11g01,192.168.1.190’ (RSA) to the list of known hosts.
grid@ora11g01’s password:
The user may be prompted for a password or passphrase here since the script would be using SCP for host ora11g01.
grid@ora11g01’s password: 


== Por fim, as validações
–ora11g01:–
Running /usr/bin/ssh -x -l grid ora11g01 date to verify SSH connectivity has been setup from local host to ora11g01.
IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL. Please note that being prompted for a passphrase may be OK but being prompted for a password is ERROR.
Fri May 15 10:36:23 BRT 2015
——————————————————————– –ora11g02:–
Running /usr/bin/ssh -x -l grid ora11g02 date to verify SSH connectivity has been setup from local host to ora11g02.
IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL. Please note that being prompted for a passphrase may be OK but being prompted for a password is ERROR.
Fri May 15 10:36:23 BRT 2015
——————————————————————– ——————————————————————–
Verifying SSH connectivity has been setup from ora11g01 to ora11g01
——————————————————————– IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL.
Fri May 15 10:36:23 BRT 2015
——————————————————————– ——————————————————————–
Verifying SSH connectivity has been setup from ora11g01 to ora11g02
——————————————————————–IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL.
Fri May 15 10:36:23 BRT 2015
——————————————————————– -Verification from ora11g01 complete-
——————————————————————–Verifying SSH connectivity has been setup from ora11g02 to ora11g01
——————————————————————– IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL.
Fri May 15 10:36:24 BRT 2015
——————————————————————–
——————————————————————–
Verifying SSH connectivity has been setup from ora11g02 to ora11g02
——————————————————————–
IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL.
Fri May 15 10:36:24 BRT 2015
——————————————————————– -Verification from ora11g02 complete-
SSH verification complete.
É isso, simples assim.
Abraço
Mario

Leave a Reply

Your email address will not be published. Required fields are marked *