初始化脚本
init.sh
#!/bin/bash
sudo apt update && sudo apt install -y git
# 配置 ssh
## 1.根据输入信息生成密钥对
echo "Please enter your email address:"
read email
ssh-keygen -t ed25519 -C $email
echo "Key has been generated successfully! Your public key is:"
cat ~/.ssh/id_ed25519.pub
## 2.信任输入的公钥,循环直到输入空白
echo "Please enter the public key you want to trust:"
read pubkey
while [ -n "$pubkey" ]
do
echo $pubkey >> ~/.ssh/authorized_keys
echo "Please enter the public key you want to trust(Only press Enter to exit):"
read pubkey
done
# 配置 git
## 1.设置用户名和邮箱
echo "Please enter your name:"
read name
echo "Please enter your email address:"
read email
git config --global user.name $name
git config --global user.email $email
## 2.设置默认branch
git config --global init.defaultBranch master