Skip to content

Instantly share code, notes, and snippets.

@fqzz
fqzz / config-vm.sh
Created September 5, 2018 07:48
config vm
set -x
set -e
HOSTNAME=$4
HOSTIP=$3
PASSWD=$2
USERNAME=$1
ssh-keyscan -H $HOSTIP >> ~/.ssh/known_hosts
sshpass -p "$PASSWD" ssh-copy-id -i ~/.ssh/id_rsa.pub $USERNAME@$HOSTIP
ssh $USERNAME@$HOSTIP "echo 'echo \""$USERNAME" ALL=(ALL) NOPASSWD:ALL\" | EDITOR=\"tee -a\" visudo' > /tmp/editsudo.sh"