parent
50fb52c127
commit
a90a40eb58
@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
|
||||
# this script will
|
||||
# - disable root ssh
|
||||
# - disable password ssh
|
||||
# - create a new user with sudo
|
||||
# - give them ssh from root (OR override with creds in current dir)
|
||||
# - install:
|
||||
# - go
|
||||
# - zsh
|
||||
# - ohmyzsh (+theme +config +plugins)
|
||||
# - nvim (+nvchad +my nvchad config)
|
||||
|
||||
read -p "Enter a username: " user
|
||||
read -p "Enter a password: " pw
|
||||
|
||||
# disable root and password ssh
|
||||
echo "Configuring SSH..."
|
||||
sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
|
||||
sed -i "s/PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
|
||||
systemctl restart ssh
|
||||
# remove root password
|
||||
echo "Removing root password..."
|
||||
passwd -dl root > /dev/null
|
||||
|
||||
# if user doesn't exist, make them and make their .ssh folder
|
||||
id -u marcy > /dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "Adding user $user..."
|
||||
useradd -s /bin/bash -d /home/$user/ -m -G sudo $user
|
||||
echo $user:$pw | chpasswd
|
||||
mkdir /home/$user/.ssh
|
||||
else
|
||||
echo "User $user already exists! Continuing..."
|
||||
fi
|
||||
|
||||
echo "Installing SSH keys..."
|
||||
# get authorized_keys from root OR prompt user to paste it in
|
||||
if [ -f /root/.ssh/authorized_keys ]; then
|
||||
# install root authorized keys
|
||||
echo "Installing authorized_keys from root..."
|
||||
cp /root/.ssh/authorized_keys /home/$user/.ssh/authorized_keys
|
||||
else
|
||||
# install ssh creds from input
|
||||
echo "No authorized_keys found in root. Enter your public key, followed by an exclamation point (!):"
|
||||
read -d '!' authkeys
|
||||
touch /home/$user/.ssh/authorized_keys
|
||||
echo "$authkeys" > /home/$user/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
# get id_rsa from root OR prompt user to paste private key in
|
||||
if [ -f /root/.ssh/id_rsa ]; then
|
||||
# install current dir ssh creds
|
||||
echo "Installing id_rsa from root..."
|
||||
cp /root/.ssh/id_rsa /home/$user/.ssh/id_rsa
|
||||
else
|
||||
# install ssh creds from input
|
||||
echo "No id_rsa found in root. Enter your id_rsa key, followed by an exclamation point (!):"
|
||||
read -d '!' idrsa
|
||||
touch /home/$user/.ssh/id_rsa
|
||||
echo "$idrsa" > /home/$user/.ssh/id_rsa
|
||||
fi
|
||||
|
||||
# give ssh creds correct perms + ownership
|
||||
chmod 0700 /home/$user/.ssh
|
||||
chmod 0600 /home/$user/.ssh/authorized_keys
|
||||
chmod 0600 /home/$user/.ssh/id_rsa
|
||||
chown $user /home/$user/.ssh
|
||||
chown $user /home/$user/.ssh/authorized_keys
|
||||
chown $user /home/$user/.ssh/id_rsa
|
||||
|
||||
# install packages + update apt
|
||||
echo "Updating and installing packages..."
|
||||
# apt update -y && apt upgrade -y
|
||||
pacman -Syu
|
||||
pacman -S zsh gcc zip unzip ripgrep fd-find git -y
|
||||
|
||||
# make zsh default shell
|
||||
chsh -s $(which zsh) $user
|
||||
|
||||
### run all subsequent commands as $user
|
||||
# for some reason this specific command breaks if its in the block after 'su #user <<EOF'
|
||||
echo "Installing oh-my-zsh..."
|
||||
su $user -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended'
|
||||
|
||||
su $user <<EOF
|
||||
cd ~
|
||||
|
||||
# configure git
|
||||
echo "Configuring Git..."
|
||||
git config --global user.name "Gabe Farrell"
|
||||
git config --global user.email "gabe@mnrva.dev"
|
||||
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
|
||||
|
||||
# configure zsh
|
||||
echo "Configuring ZSH..."
|
||||
mkdir ~/.zsh
|
||||
echo "Installing zsh theme..."
|
||||
curl -fsSL "https://raw.githubusercontent.com/moarram/headline/main/headline.zsh-theme" >> ~/.zsh/headline.zsh-theme
|
||||
echo "Installing zsh config..."
|
||||
curl -fsSL "https://gist.githubusercontent.com/mnrva-dev/8c82409e041c59145d27d02939d50d19/raw/a01cfb09fe31a36b56ecbf1211862a29e1db276d/gistfile1.txt" >> ~/.zshrc
|
||||
echo "Installing zsh plugins..."
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
|
||||
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
|
||||
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete
|
||||
|
||||
# install nvim + nvchad + configure nvchad
|
||||
echo "Installing nVim..."
|
||||
wget https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz
|
||||
tar xzvf nvim-linux64.tar.gz
|
||||
|
||||
echo "Configuring NVChad..."
|
||||
git clone https://github.com/NvChad/starter ~/.config/nvim
|
||||
rm -rf ~/.config/nvim/.git
|
||||
rm -rf ~/.config/nvim/lua/custom
|
||||
git clone git@github.com:gabehf/nvchad-custom.git ~/.config/nvim/lua/custom
|
||||
EOF
|
||||
|
||||
echo "Done!"
|
||||
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "please run as root!"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$1" ]; then
|
||||
echo "specify a go version to update to"
|
||||
exit 1
|
||||
fi
|
||||
echo "Downloading new Go version..."
|
||||
wget -P /home/marcy/ "https://go.dev/dl/go$1.linux-amd64.tar.gz"
|
||||
echo "Removing current Go installation..."
|
||||
rm -rf /usr/local/go
|
||||
echo "Installing new Go version..."
|
||||
tar -C /usr/local -xzf "/home/marcy/go$1.linux-amd64.tar.gz"
|
||||
echo "Cleaning up..."
|
||||
rm "/home/marcy/go$1.linux-amd64.tar.gz"
|
||||
echo "Done!"
|
||||
Loading…
Reference in new issue