Skip to content

Instantly share code, notes, and snippets.

@fqzz
Created September 5, 2018 07:48
Show Gist options
  • Save fqzz/ccaf464c2722a6a84bc73a4ebc5db5b2 to your computer and use it in GitHub Desktop.
Save fqzz/ccaf464c2722a6a84bc73a4ebc5db5b2 to your computer and use it in GitHub Desktop.
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"
ssh $USERNAME@$HOSTIP 'echo -e "'$PASSWD'\n" | sudo -S bash /tmp/editsudo.sh'
ssh $USERNAME@$HOSTIP 'sudo hostname '$HOSTNAME
ssh $USERNAME@$HOSTIP 'echo -n '$HOSTNAME' | sudo tee /etc/hostname'
ssh $USERNAME@$HOSTIP 'sudo sed -i "s/127.0.0.1.*/127.0.0.1 '$HOSTNAME'/g" /etc/hosts'
ssh $USERNAME@$HOSTIP 'sudo sed s/us.archive.ubuntu.com/mirrors.aliyun.com/g -i /etc/apt/sources.list'
ssh $USERNAME@$HOSTIP 'sudo sed s/mirrors.tuna.tsinghua.edu.cn/mirrors.aliyun.com/g -i /etc/apt/sources.list'
ssh $USERNAME@$HOSTIP 'sudo sed s/download.docker.com/mirrors.aliyun.com\\/docker-ce/g -i /etc/apt/sources.list'
ssh $USERNAME@$HOSTIP 'sudo usermod -aG docker '$USERNAME
ssh $USERNAME@$HOSTIP 'sudo locale-gen zh_CN.UTF-8 en_US.UTF-8'
ssh $USERNAME@$HOSTIP 'sudo update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANGUAGE=en_US'
ssh $USERNAME@$HOSTIP 'sudo dpkg-reconfigure --frontend noninteractive locales'
ssh $USERNAME@$HOSTIP 'sudo apt update'
ssh $USERNAME@$HOSTIP 'sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y'
ssh $USERNAME@$HOSTIP 'sudo DEBIAN_FRONTEND=noninteractive apt install -y zsh'
ssh $USERNAME@$HOSTIP 'sudo chsh -s $(which zsh) `whoami`'
ssh $USERNAME@$HOSTIP 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment