bash script multiple servers sudo

while read HOST ; do ssh someuser@$HOST “sudo yum install -y python-ksplice-uptrack” < /dev/null; done <all_servers

Advertisements

Add to remote server fstab via script

ssh root@192.0.0.1 ‘sh -‘ < nfs_mount.sh

#!/bin/bash

mkdir -p /mnt/somedir
echo 'anyhost.domain.com:/vol/somedir /mnt/somedir nfs rw,fg,nfsvers=3,tcp,rsize=65536,wsize=65536,timeo=600,hard,intr' | tee -a /etc/fstab
mount /mnt/somedir

change user shell to bin false

RHEL/Cent OS

# usermod -s /sbin/nologin username

or

change the shell from /bin/bash to /sbin/nologin

not affected by this shell (/sbin/nologin):

FTP clients
mail clients
sudo
many setuid programs

prevents access to the shell and logs the attempt. All of the following programs are prevented from accessing the user account:

telnet/login
gdm/kdm/xdm (graphical login)
su
ssh/scp/sftp etc

Debian / Ubuntu

$ sudo usermod -s /bin/false username

or

# sudo usermod -s /bin/false username

or

another way – touch /etc/nologin