From 8414b662da298848d357497dc3bc57d47533a2fa Mon Sep 17 00:00:00 2001 From: Dmitry <124861781+ada-dmitry@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:51:24 +0300 Subject: [PATCH] =?UTF-8?q?feat(bootstrap):=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B8=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B8=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=BA=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20feat(ssh):=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8E=20SSH=20=D1=81=20=D0=BD=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=BC=D0=B8=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=B8=20=D0=B8=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=83=D1=81=D1=82=D0=B0=D1=80=D0=B5=D0=B2=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + bootstrap.sh | 73 +++++++++++++++++++++++++++++ ssh/.ssh/config.d/00-globals.conf | 22 +++++++-- ssh/.ssh/config.d/10-local.conf | 3 -- ssh/.ssh/config.d/30-corporate.conf | 44 +---------------- 5 files changed, 94 insertions(+), 49 deletions(-) create mode 100644 bootstrap.sh diff --git a/README.md b/README.md index bd7a7ca..9b600db 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ ```bash git clone ~/.dotfiles cd ~/.dotfiles +mkdir -p ~/.ssh/sockets stow -t ~ */ ``` diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..11dde25 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -euo pipefail + +PACKAGES=("zsh" "tmux" "alacritty" "stow") + +# Detect package manager and install. +detect_and_install() { + if command -v apt &>/dev/null; then + echo "Detected: apt (Debian/Ubuntu)" + sudo apt update + sudo apt install -y "${PACKAGES[@]}" + elif command -v pacman &>/dev/null; then + echo "Detected: pacman (Arch)" + sudo pacman -Syu --noconfirm "${PACKAGES[@]}" + elif command -v dnf &>/dev/null; then + echo "Detected: dnf (Fedora/RHEL)" + sudo dnf install -y "${PACKAGES[@]}" + elif command -v zypper &>/dev/null; then + echo "Detected: zypper (openSUSE)" + sudo zypper install -y "${PACKAGES[@]}" + elif command -v brew &>/dev/null; then + echo "Detected: brew (macOS)" + brew install "${PACKAGES[@]}" + else + echo "Error: No supported package manager found" + echo "Please install: ${PACKAGES[*]}" + exit 1 + fi +} + +# Check if all packages are already installed. +check_installed() { + local missing=() + for pkg in "${PACKAGES[@]}"; do + if ! command -v "$pkg" &>/dev/null; then + missing+=("$pkg") + fi + done + + if [[ ${#missing[@]} -gt 0 ]]; then + echo "Missing packages: ${missing[*]}" + detect_and_install + else + echo "All required packages already installed." + fi +} + +check_installed + +# Basic setup for this dotfiles repo. +mkdir -p "$HOME/.ssh/sockets" +echo "Created ~/.ssh/sockets" + +# Apply all stow packages. +cd "$(dirname "$0")" +echo "Running: stow -t $HOME */" +stow -t "$HOME" */ + +# Set zsh as default shell. +set_default_shell() { + local zsh_path + zsh_path=$(command -v zsh) + + read -p "Set zsh as default shell? (y/n) " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + chsh -s "$zsh_path" + echo "Default shell changed to: $zsh_path" + fi +} + +set_default_shell +echo "Bootstrap complete!" diff --git a/ssh/.ssh/config.d/00-globals.conf b/ssh/.ssh/config.d/00-globals.conf index c2486c6..9d0af37 100644 --- a/ssh/.ssh/config.d/00-globals.conf +++ b/ssh/.ssh/config.d/00-globals.conf @@ -2,9 +2,25 @@ Host * # Переиспользование соединений (быстрее) - # ControlMaster auto - # ControlPath ~/.ssh/sockets/%r@%h:%p - # ControlPersist 10m + ControlMaster auto + ControlPath ~/.ssh/sockets/%C + ControlPersist 10m + + # Автоматически добавлять ключи в агент + AddKeysToAgent yes + + # Использовать только явно заданные ключи + IdentitiesOnly yes + + # Таймауты подключения + ConnectTimeout 10 + ConnectionAttempts 2 + + # Обновлять ключи хоста при ротации + UpdateHostKeys yes + + # Хэшировать known_hosts + HashKnownHosts yes # Держать соединение живым ServerAliveInterval 60 diff --git a/ssh/.ssh/config.d/10-local.conf b/ssh/.ssh/config.d/10-local.conf index faa2a8c..4f5d4de 100644 --- a/ssh/.ssh/config.d/10-local.conf +++ b/ssh/.ssh/config.d/10-local.conf @@ -1,6 +1,3 @@ -# 10 - Local network (direct IP) - -# ПК Host ada-pc HostName 192.168.1.100 User ada diff --git a/ssh/.ssh/config.d/30-corporate.conf b/ssh/.ssh/config.d/30-corporate.conf index 118c04c..3830945 100644 --- a/ssh/.ssh/config.d/30-corporate.conf +++ b/ssh/.ssh/config.d/30-corporate.conf @@ -1,48 +1,6 @@ -# 40 - Corporate (PAO IL) - -Host ada-alt - HostName 127.0.0.1 - User ada-alt - Port 3322 - IdentityFile ~/.ssh/id_ed25519 - StrictHostKeyChecking no - UserKnownHostsFile /dev/null - - -Host pam - HostName 10.1.194.230 - User antipenkoda@MSK.LAN - Port 2244 - ProxyJump ada-alt - StrictHostKeyChecking no - UserKnownHostsFile /dev/null - - -Host master-ans - HostName 10.1.194.160 - User ada - IdentityFile /home/ada/.ssh/id_ed25519_ada - ProxyJump pam - LocalForward 9000 localhost:22 - StrictHostKeyChecking no - UserKnownHostsFile /dev/null - -Host master-ans-direct - HostName localhost - Port 9000 - User ada - SetEnv TERM=xterm-256color - -Host gitea - HostName 10.1.194.243 - User gitea - IdentityFile ~/.ssh/id_ed25519_ada - ProxyJump pam - - Host devel.mephi.ru HostName devel.mephi.ru - IdentityFile ~/.ssh/id_ed25519_ada + IdentityFile ~/.ssh/id_ed25519 KexAlgorithms +curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256 Host github.com