N-C

Aller au contenu | Aller au menu | Aller à la recherche

Bugs resolves - astuces

Fil des billets - Fil des commentaires

mercredi 15 juin 2016

SSH command and usefull option

many option about ssh command are not describe into man, and when you need to automatic some script, it could be usefull to bypath some ask from default ssh command

exemple : (more info into man ssh_config)

  • ConnectTimeout=xx is about to stop connection if no reply after x sec
  • PasswordAuthentication=yes|no   Dont ask password (default yes)
  • ChallengeResponseAuthentication=yes|no   (default yes)
  • BatchMode=yes|no  this disable passphrase / password ask , really usefull for scripting (default no)
  • StrictHostKeyChecking=yes|no|ask  (default ask) usefull to add automatically new server authkey into ~/.ssh/known_hosts whitout asking

a usefull ssh  command exemple :

LISTE_SERV=/Path_list

LOG_OUT=/PATH_log

# for i in `cat $LISTE_SERV` ; do ssh $i -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o ChallengeResponseAuthentication=no "command into ssh tunnel" >> $LOG_OUT ; done

 To copy ssh public key on remote server using SSH :

cat ~/.ssh/id_dsa.pub | ssh ${username}@${remote_server} "touch ~/.ssh/authorized_keys && cat - >> ~/.ssh/authorized_keys" ; exit 0


To get more options about scanning all your Unix-Linux information system you can use this script as below.

mercredi 4 mai 2016

HowTo create mirror LVM with pacemaker HA-cluster RHEL 7


hi,

here about a tips to add / remove an LV using raid mirror with multiple slice and all that with HA-cluster RHEL 7.1

HA-cluster is monitored by Pacemaker

why this ticket ?

Just becaus there is a redhat bug implementation and RedHat support don't find alone solution.

So, first the need is : (we have already 4 PV using multipath, and 1 VG "vgtest" already using pacemaker resource)

lvcreate -m1 -i2 -I 128 -L 200m -n test4 vgtest /dev/mapper/pv1-1 /dev/mapper/pv2-1 /dev/mapper/pv1-2 /dev/mapper/pv2-2


First, we have to stop resource onto active node
pcs resource disable $resource_name_vgtest

then we need to reconfigure /etc/lvm/lvm.conf

locking_type = 1
ignore_lvm_mirrors = 0 => (set 1 if ou need remove a failed or inactive  LV/VG)
use_lvmetad = 1
## Add the VG into locale volume list group:
volume_list = [ "vgroot", "vgtest" ]

reload lvm :
systemctl restart lvm2-lvmetad

# create your LV with raid 1 onto 4 slice #
lvcreate -m1 -i2 -I 128 -L 200m -n test4 vgtest /dev/mapper/pv1-1 /dev/mapper/pv2-1 /dev/mapper/pv1-2 /dev/mapper/pv2-2
# format it - default xfs under RHEL 7 #
mkfs.xfs /dev/vgtest/test4  or /dev/mapper/vgtest-test4


## backoff local LV to cluster ##
edit /etc/lvm/lvm.conf and change to this properties
 volume_list = [ "vgroot" ]

# reload lvm service
systemctl restart lvm2-lvmetad

# enable pacemaker resource
pcs resource enable $resource_name_vgtest


You can check it :
pcs resource  || pcs status
## all have to be "started" ##

## Then you can mount this Lv as any other FileSystem mount method ##

## If not all started, use a clean to purge all failed and redetect status
pcs resource cleanup $Resource_name

mardi 14 mai 2013

VMware et CentOs : Changer le nom d'une interface Ethernet

à la différence d'un serveur NON virtualisé, où il faut simplement renommer le fichier :

mv /etc/sysconfig/network-scripts/ifcfg-eth(x)  /etc/sysconfig/network-scripts/ifcfg-eth0

et

éditer le fichier :

changer : DEVICE="eth(x)"  par DEVICE="eth0"

vim /etc/sysconfig/network-scripts/ifcfg-eth0

Pour VmWare il faut aussi supprimer une règle persistance de udev :

vim /etc/udev/rules.d/70-persistent-net.rules

Remplacer eth(x) par eth0

Puis rebooter.


mardi 4 décembre 2012

SSH : Desactiver le contrôle known_hosts

Lorsque l'on fait un accès SSH d'un client vers un serveur (sshd), côté client il contrôle la clef public du serveur enregistrer dans ~/.ssh/known_hosts. Afin d'éviter les attack man-in-the-middle.

Mais si vous voulez vous passez de ce contrôle afin de lancer des scripts de déploiement par exemple sans problème : 2 choses à faire.

- ne pas avoir l'entrée du serveurs dans : ~/.ssh/known_hosts

- soit se connecter ainsi : ssh -o StrictHostKeychecking=no "serveur_distant" (n'ajoute pas l'entrée dans ~/.ssh/known_hosts)

ou bien que cela soit fait de manière permanante :

echo  "UserKnownHostsFile=/dev/null" >> /etc/ssh/ssh_config

mardi 24 avril 2012

[ssh] exécuter un script d'un server A vers un server B

Depuis Server A :

cat /tmp/testssh
#!/bin/bash
echo "toto" >> /tmp/testtoto

execution :

cat /tmp/testssh |ssh linuxadmin2 "/bin/sh"


Vérification sur server B :

cat /tmp/testtoto
toto


## Recuperation des informations techniques d'un serveur ##
## depuis un serveur central : via un compte d'exploitation : user
## CPU / RAM / Disk / OS release / IP ##

LIST_CIBLE='/PATH_LIST'
USER_SSH='user'
SSH_KEY=~/.ssh/id_dsa
SSH_COMM='ssh -T -i '$SSH_KEY'  -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o ChallengeResponseAuthentication=no'


LOG_OUT='./scan.log_out'
ROTATE_LOG_OUT='./scan_cmdb.log_out.old'

mv $LOG_OUT $ROTATE_LOG_OUT
echo "NAME;OS;Number_of_Logical_Processor;RAM Allocated"

for i in $LIST_CIBLE
        do
$SSH_COMM $USER_SSH@$i <<'EOF'
echo "`hostname`;`head -1 /etc/redhat-release`;`grep -c ^processor /proc/cpuinfo`;`free -g | awk '/Mem/ {print \$2}'`"
EOF
done >> $LOG_OUT


- page 1 de 2