Linux配置
Ubuntu
Kali
通用
配置Hexo环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #!/bin/bash set -e
target_username=git target_password=root useradd -m git echo -e "${target_password}\n${target_password}" | sudo passwd ${target_username} echo 'git ALL=(ALL:ALL) ALL' | sudo tee -a /etc/sudoers
su git <<Code sudo mkdir /var/repo/ sudo chown -R $USER:$USER /var/repo/ sudo chmod -R 755 /var/repo/ cd /var/repo/ sudo git init --bare hexo_static.git Code
su git <<Code sudo apt update sudo apt install nginx -y sudo mkdir -p /var/www/hexo sudo chown -R $USER:$USER /var/www/hexo sudo chmod -R 755 /var/www/hexo sudo sed -i 's@root /var/www/html;@root /var/www/hexo;@g' /etc/nginx/sites-enabled/default sudo service nginx restart Code
su git <<Code sudo touch /var/repo/hexo_static.git/hooks/post-receive sudo sh -c "echo '#!/bin/bash' >> /var/repo/hexo_static.git/hooks/post-receive" sudo sh -c "echo 'git --work-tree=/var/www/hexo --git-dir=/var/repo/hexo_static.git checkout -f' >> /var/repo/hexo_static.git/hooks/post-receive" sudo chmod +x /var/repo/hexo_static.git/hooks/post-receive Code
su git <<Code sudo mkdir -p ~/.ssh #新建一个.ssh文件夹 sudo touch ~/.ssh/authorized_keys #新建一个.authorized_keys sudo chmod 600 ~/.ssh/authorized_keys #该权限是保证git用户免密登录推送文件必要步骤 sudo chmod 700 ~/.ssh sudo sh -c "echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDBe/UsMlJRIL+Z4w0DTr9nRmKu8Tt9cPoKj/t7fOHWItBPxMaVryrq732nIkZlCrtpJNkZJsfN9Fq2oGHyA/x3qrXBjhNiFUx2NTRHPlcfVMfTf+XB34oa4eAHOEWpkxCDZe+W0nV3va8sp7poSQqA+GD+YmidZ8dR57TQdfnTTFB9SIW7DZBATRseUzf/PtPRTVh7Jn/963M/JHVhV+OHXJ0BRCvu0YBg/oqxPkWJ41kZOZJP6KfDVICgoERgULRdnYWLNUUNlLOQ4LPDG3fhQHJgN2L9hqjf0bk5Zx5ZA9Uy093AAdkyElY2rkxeN9hwOZT/YFEbvUAT0v2kDtf1TM8lfuO3ibD2j9Pxetv/jUKNthliSmdeB/+tD6hkJ6/mdjvoIgqATY2YlEIM7YYTAZ4mVaqAbYKx3HHDRlj7Jd2wUEGuOFcuzvqIsIHTfSzcydvUBW04zLUKAl/Zacp0mi+wmbgyX3gZYO6nhFCjmQPaO2KyNLrArYepWifDnlk= d4wn@D4wn' > /home/git/.ssh/authorized_keys" Code
|
参考:https://cnhuazhu.top/next/2021/10/12/%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%88Ubuntu%EF%BC%89/Hexo%E9%83%A8%E7%BD%B2%E8%87%B3%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%88Ubuntu-20-04%EF%BC%89/#%E7%8E%AF%E5%A2%83
Ubuntu22.04
允许root本地登录
设置Root密码
注释文件行
找到/etc/pam.d/gdm-password
和/etc/pam.d/gdm-autologin
注释auth required pam_succeed_if.so user != root quiet_success
修改/root/.profile
文件
注释mesg n 2> /dev/null || true
插入如下行
1
| tty -s && mesg n || true
|
允许Root远程登录
安装ssh
1 2
| apt update apt install openssh-server
|
修改ssh配置文件
重启ssh
安装设置Proxychains代理
1 2 3 4 5 6 7 8 9 10 11 12 13
| sudo apt install -y proxychains4 total_lines=$(wc -l < /etc/proxychains4.conf) second_to_last_line=$((total_lines - 1)) sudo sed -i "${second_to_last_line}s/.*/socks5 192.168.1.109 10810/" /etc/proxychains4.conf sudo echo "alias p='proxychains4'" | sudo tee -a /root/.bashrc
```bash wget -P /root/ https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh chmod +x /root/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh bash /root/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh -b -p /root/miniconda3 /root/miniconda3/bin/conda init $(echo $SHELL | awk -F '/' '{print $NF}')
|
开机自动登录Root
1 2
| sudo touch /etc/gdm3/custom.conf echo -e "[daemon]\nAutomaticLoginEnable=true\nAutomaticLogin=root" | sudo tee -a /etc/gdm3/custom.conf
|
jupyter
notebook配置允许远程登录同时关闭密码
1 2 3 4
| jupyter notebook --generate-config 找到生成的配置文件,配置如下 c.NotebookApp.ip = '*' c.NotebookApp.token = ''
|
一键安装脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #!/bin/bash set -e proxy_ip="192.168.1.109" target_username=root target_password=root
echo -e "${target_password}\n${target_password}" | sudo passwd ${target_username}
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password
sudo sed -i 's/^mesg.*/tty -s \&\& mesg n \|\| true/' /root/.profile
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list sudo apt update
sudo apt install -y openssh-server
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo systemctl restart ssh
sudo apt install -y vim sudo apt install -y proxychains4
total_lines=$(wc -l < /etc/proxychains4.conf) second_to_last_line=$((total_lines - 1)) sudo sed -i "${second_to_last_line}s/.*/socks5 192.168.1.109 10810/" /etc/proxychains4.conf sudo echo "alias p='proxychains4'" | sudo tee -a /root/.bashrc
sudo -s <<EOF wget -P /root/ https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh chmod +x /root/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh bash /root/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh -b -p /root/miniconda3 /root/miniconda3/bin/conda init $(echo $SHELL | awk -F '/' '{print $NF}') /root/miniconda3/bin/conda create -n d2l python=3.8 -y source /root/miniconda3/bin/activate d2l /usr/bin/proxychains4 pip install d2l jupyter torch torchvision EOF
sudo touch /etc/gdm3/custom.conf echo -e "[daemon]\nAutomaticLoginEnable=true\nAutomaticLogin=root" | sudo tee -a /etc/gdm3/custom.conf
|
ubuntu20.04
一键安装脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #!/bin/bash set -e proxy_ip="192.168.1.109" target_username=root target_password=root
echo -e "${target_password}\n${target_password}" | sudo passwd ${target_username}
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password
sudo sed -i 's/^mesg.*/tty -s \&\& mesg n \|\| true/' /root/.profile
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse" | sudo tee /etc/apt/sources.list echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list sudo apt update
sudo apt install -y openssh-server
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo systemctl restart ssh
sudo apt install -y vim sudo apt install -y proxychains4
total_lines=$(wc -l < /etc/proxychains4.conf) second_to_last_line=$((total_lines - 1)) sudo sed -i "${second_to_last_line}s/.*/socks5 192.168.1.109 10810/" /etc/proxychains4.conf sudo echo "alias p='proxychains4'" | sudo tee -a /root/.bashrc
sudo -s <<EOF wget -P /root/ https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh chmod +x /root/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh bash /root/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh -b -p /root/miniconda3 /root/miniconda3/bin/conda init $(echo $SHELL | awk -F '/' '{print $NF}') EOF
sudo touch /etc/gdm3/custom.conf echo -e "[daemon]\nAutomaticLoginEnable=true\nAutomaticLogin=root" | sudo tee -a /etc/gdm3/custom.conf
|