From c332cf11dc0266f31eeae067ace5a9bda18122c6 Mon Sep 17 00:00:00 2001 From: Super User Date: Mon, 23 Mar 2026 19:09:37 +0800 Subject: flatten setup directory structure --- core/install-packages.sh | 27 ++++++++++ core/packages/install_claude.sh | 8 +++ core/packages/install_rust.sh | 7 +++ core/ssh.sh | 12 +++++ core/tmux.conf | 11 ++++ core/tmux.sh | 5 ++ core/vim.sh | 66 +++++++++++++++++++++++ git/set-global_user.sh | 2 + git/tools/git-ssh-wrapper.sh | 2 + git/tools/usefulbutnotthatusefulidkwhattodo | 0 port-forward/persistent-ssh.sh | 35 ++++++++++++ port-forward/rm_all_ssh_connections.sh | 4 ++ port-forward/ssh-multiport-forward.sh | 44 +++++++++++++++ port-forward/ssh-port-forward.sh | 19 +++++++ setup.sh | 21 ++++++++ setup/core/install-packages.sh | 27 ---------- setup/core/packages/install_claude.sh | 8 --- setup/core/packages/install_rust.sh | 7 --- setup/core/ssh.sh | 12 ----- setup/core/tmux.conf | 11 ---- setup/core/tmux.sh | 5 -- setup/core/vim.sh | 66 ----------------------- setup/git/set-global_user.sh | 2 - setup/git/tools/git-ssh-wrapper.sh | 2 - setup/git/tools/usefulbutnotthatusefulidkwhattodo | 0 setup/port-forward/persistent-ssh.sh | 35 ------------ setup/port-forward/rm_all_ssh_connections.sh | 4 -- setup/port-forward/ssh-multiport-forward.sh | 44 --------------- setup/port-forward/ssh-port-forward.sh | 19 ------- setup/setup.sh | 21 -------- 30 files changed, 263 insertions(+), 263 deletions(-) create mode 100755 core/install-packages.sh create mode 100755 core/packages/install_claude.sh create mode 100755 core/packages/install_rust.sh create mode 100755 core/ssh.sh create mode 100644 core/tmux.conf create mode 100755 core/tmux.sh create mode 100755 core/vim.sh create mode 100755 git/set-global_user.sh create mode 100755 git/tools/git-ssh-wrapper.sh create mode 100644 git/tools/usefulbutnotthatusefulidkwhattodo create mode 100755 port-forward/persistent-ssh.sh create mode 100755 port-forward/rm_all_ssh_connections.sh create mode 100755 port-forward/ssh-multiport-forward.sh create mode 100755 port-forward/ssh-port-forward.sh create mode 100755 setup.sh delete mode 100755 setup/core/install-packages.sh delete mode 100755 setup/core/packages/install_claude.sh delete mode 100755 setup/core/packages/install_rust.sh delete mode 100755 setup/core/ssh.sh delete mode 100644 setup/core/tmux.conf delete mode 100755 setup/core/tmux.sh delete mode 100755 setup/core/vim.sh delete mode 100755 setup/git/set-global_user.sh delete mode 100755 setup/git/tools/git-ssh-wrapper.sh delete mode 100644 setup/git/tools/usefulbutnotthatusefulidkwhattodo delete mode 100755 setup/port-forward/persistent-ssh.sh delete mode 100755 setup/port-forward/rm_all_ssh_connections.sh delete mode 100755 setup/port-forward/ssh-multiport-forward.sh delete mode 100755 setup/port-forward/ssh-port-forward.sh delete mode 100755 setup/setup.sh diff --git a/core/install-packages.sh b/core/install-packages.sh new file mode 100755 index 0000000..fb0a75d --- /dev/null +++ b/core/install-packages.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Install core packages +sudo dnf install -y epel-release +#sudo dnf group install -y "Development Tools" +sudo dnf install -y nc openssl bat autossh tmux htop tar bmon gzip tree wget curl plocate nano vim unzip net-tools git python3 python3-pip make wireguard-tools usbutils yum +sudo dnf install -y xclip + +sudo dnf install -y gcc gcc-c++ openssl-devel +sudo dnf install -y java-latest-openjdk-devel +#sudo dnf install -y asio-devel boost-devel openssl-devel + +# Execute all package installation scripts +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +for script in "$SCRIPT_DIR/packages"/*.sh; do + if [ -f "$script" ]; then + "$script" + fi +done + +#install packages ml +#pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 +#pip3 install transformers + +#sudo yum install -y python3-openstackclient s3fs-fuse awscli +#pip install jupyterlab python-swiftclient +#sudo dnf update -y diff --git a/core/packages/install_claude.sh b/core/packages/install_claude.sh new file mode 100755 index 0000000..99a881d --- /dev/null +++ b/core/packages/install_claude.sh @@ -0,0 +1,8 @@ +#!/bin/bash +sudo dnf install -y tar +# Install Node.js via nvm and Claude Code +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +nvm install 22 +npm install -g @anthropic-ai/claude-code diff --git a/core/packages/install_rust.sh b/core/packages/install_rust.sh new file mode 100755 index 0000000..921a533 --- /dev/null +++ b/core/packages/install_rust.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Install Rust and Cargo tools +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +echo '[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"' >> ~/.bashrc +source "$HOME/.cargo/env" +cargo install cargo-clone-crate cargo-edit cargo-info evcxr_jupyter bacon du-dust ripgrep bandwhich diff --git a/core/ssh.sh b/core/ssh.sh new file mode 100755 index 0000000..c4454ae --- /dev/null +++ b/core/ssh.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +dnf install -y git + +echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config +echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config +echo "GatewayPorts yes" | sudo tee -a /etc/ssh/sshd_config +echo "AllowAgentForwarding yes" | sudo tee -a /etc/ssh/sshd_config + +git clone https://git.noml.ch/keys/ ~/keys +~/keys/add-ssh-keys.sh +sudo systemctl restart sshd diff --git a/core/tmux.conf b/core/tmux.conf new file mode 100644 index 0000000..f01bf59 --- /dev/null +++ b/core/tmux.conf @@ -0,0 +1,11 @@ +# Vi mode for copy +setw -g mode-keys vi + +# Mouse selection +set -g mouse on + +# v to start selection, y to yank (like vim) +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" diff --git a/core/tmux.sh b/core/tmux.sh new file mode 100755 index 0000000..1e5d3db --- /dev/null +++ b/core/tmux.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit + +cp tmux.conf /etc/tmux.conf diff --git a/core/vim.sh b/core/vim.sh new file mode 100755 index 0000000..bd99a13 --- /dev/null +++ b/core/vim.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit + +VIMRC_PATH="/etc/vimrc" +[ -d /etc/vim ] && VIMRC_PATH="/etc/vim/vimrc" +CLIP_HOST="p.noml.ch" +CLIP_PORT="5023" +CLIP_CMD="openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 ${CLIP_HOST} ${CLIP_PORT}" + +grep -q 'netcat_clipboard' "$VIMRC_PATH" && exit 0 + +cat << EOF >> "$VIMRC_PATH" +augroup netcat_clipboard + au! + au TextYankPost * call system("echo " . shellescape(@") . " | ${CLIP_CMD} >/dev/null 2>&1 &") +augroup END + +" Enable line wrapping +set wrap + +" Optional: Make wrapped lines easier to read by indenting them +set breakindent +set breakindentopt=shift:1 + +syntax on +set mouse=a +set expandtab +set shiftwidth=4 +set softtabstop=4 +set tabstop=4 +set noautoindent +set nosmartindent +filetype plugin indent on + +set laststatus=2 " permanent status bar +set statusline=%F " shows full file path + +if (has("termguicolors")) + set termguicolors +endif + +"colorscheme murphy +colorscheme zellner + +" Ctrl+A: Move to the beginning of the line in INSERT mode +inoremap + +" Ctrl+E: Move to the end of the line in INSERT mode +inoremap + +" Ctrl+A: Move to the beginning of the line in NORMAL mode +nnoremap 0 + +" Ctrl+E: Move to the end of the line in NORMAL mode +nnoremap $ + +set number +setlocal regexpengine=2 +set paste +set foldcolumn=12 + +set noswapfile +autocmd InsertLeave * silent! update + +EOF diff --git a/git/set-global_user.sh b/git/set-global_user.sh new file mode 100755 index 0000000..30e11eb --- /dev/null +++ b/git/set-global_user.sh @@ -0,0 +1,2 @@ +git config --global user.email "hc@email.ch" +git config --global user.name "hc" diff --git a/git/tools/git-ssh-wrapper.sh b/git/tools/git-ssh-wrapper.sh new file mode 100755 index 0000000..dc23334 --- /dev/null +++ b/git/tools/git-ssh-wrapper.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ssh -v -A -o ForwardAgent=yes "$@" diff --git a/git/tools/usefulbutnotthatusefulidkwhattodo b/git/tools/usefulbutnotthatusefulidkwhattodo new file mode 100644 index 0000000..e69de29 diff --git a/port-forward/persistent-ssh.sh b/port-forward/persistent-ssh.sh new file mode 100755 index 0000000..36d14dd --- /dev/null +++ b/port-forward/persistent-ssh.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +echo "selinux command is untested. copy paste systemd file if you want" +echo "reboot afterwards(selinux unset, need reboot to take effect, or just do sudo setenforce 0 for temp unset)" +echo "make sure /root/m exists" +echo "remember to change the remote port or host if needed" + +# disable selinux +sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config + +sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service +[Unit] +Description=Persistent SSH Tunnel +After=network.target +StartLimitIntervalSec=0 + +[Service] +Type=simple +ExecStart=/usr/bin/ssh \ + -i /root/m \ + -o "ExitOnForwardFailure=yes" \ + -o "StrictHostKeyChecking=no" \ + -N -R 24:localhost:22 root@p.0nom.ch +Restart=always +RestartSec=10 +RemainAfterExit=no +KillMode=process + +[Install] +WantedBy=multi-user.target +EOF + +sudo chmod 600 /root/m +sudo systemctl daemon-reload +sudo systemctl enable --now ssh-tunnel diff --git a/port-forward/rm_all_ssh_connections.sh b/port-forward/rm_all_ssh_connections.sh new file mode 100755 index 0000000..f19300d --- /dev/null +++ b/port-forward/rm_all_ssh_connections.sh @@ -0,0 +1,4 @@ +#!/bin/bash +ss -tnp | grep ':22' +ps -ef | grep sshd | grep -v grep | awk '{if($3!=1) print $2}' | xargs kill +#sudo systemctl restart sshd diff --git a/port-forward/ssh-multiport-forward.sh b/port-forward/ssh-multiport-forward.sh new file mode 100755 index 0000000..40d4ef6 --- /dev/null +++ b/port-forward/ssh-multiport-forward.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Check if at least one argument is provided +if [ $# -lt 1 ]; then + echo "Usage: $0 [additional_ports...]" + echo "Example: $0 5 80 443" + exit 1 +fi + +# First argument is the base number for port range +j=$1 +shift # Remove first argument from the list, leaving only additional ports + +HOST="root@p.0nom.ch" + +# Clean management port +echo "cleaning management port..." +ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" +echo "cleaning attempted." + +# Build the SSH command with all port forwards +SSH_CMD="ssh $HOST" + +# Add range-based port forwards (j000-j005) +for i in $(seq ${j}000 ${j}005); do + SSH_CMD+=" -R $i:localhost:$i" +done + +# Add management port forward +SSH_CMD+=" -R ${j}022:localhost:22" + +# Add additional individual port forwards from remaining arguments +for port in "$@"; do + SSH_CMD+=" -R $port:localhost:$port" +done + +# Execute the SSH command +eval $SSH_CMD + +echo "Port forwards are available on:" +echo "- Ports ${j}000-${j}005" +echo "- Management port ${j}022" +if [ $# -gt 0 ]; then + echo "- Additional ports: $@" +fi diff --git a/port-forward/ssh-port-forward.sh b/port-forward/ssh-port-forward.sh new file mode 100755 index 0000000..c4cb0a8 --- /dev/null +++ b/port-forward/ssh-port-forward.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# opens 5 ports + +#file will be run from where the user executes the script +j=$1 +HOST="root@p.0nom.ch" + +# get the process holding the specified port and kill it +echo "cleaning management port..." +ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" +echo "cleaning attempted." + +ssh $HOST $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") + +echo "port forward is available on ports ${j}000-${j}005, ssh on ${j}022" + +#ideally port forward from 2 onwards, there seems to be a problem for 1000(or just change all to j001) +#jupyter lab --port=2001 --ip=0.0.0.0 diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..f0cf83b --- /dev/null +++ b/setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" || exit + +# Shell appearance (only append if not already present) +grep -q 'di=38;5;135' /etc/bashrc || sudo tee -a /etc/bashrc > /dev/null << 'EOF' +LS_COLORS=$LS_COLORS:'di=38;5;135:ex=00;32:' ; export LS_COLORS +PS1='[\[\033[01;32m\]\u\[\033[00m\]@\h \[\033[38;5;135m\]\W\[\033[00m\]]\$ ' +export TERM=xterm-256color +EOF +source /etc/bashrc + +# Timezone +sudo timedatectl set-timezone Asia/Singapore + +# Core setup +sudo bash ./core/ssh.sh || { echo "Failed to configure SSH"; exit 1; } +sudo bash ./core/install-packages.sh || { echo "Failed to install packages"; exit 1; } +sudo bash ./core/vim.sh || { echo "Failed to configure Vim"; exit 1; } +sudo bash ./core/tmux.sh || { echo "Failed to configure Tmux"; exit 1; } diff --git a/setup/core/install-packages.sh b/setup/core/install-packages.sh deleted file mode 100755 index fb0a75d..0000000 --- a/setup/core/install-packages.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Install core packages -sudo dnf install -y epel-release -#sudo dnf group install -y "Development Tools" -sudo dnf install -y nc openssl bat autossh tmux htop tar bmon gzip tree wget curl plocate nano vim unzip net-tools git python3 python3-pip make wireguard-tools usbutils yum -sudo dnf install -y xclip - -sudo dnf install -y gcc gcc-c++ openssl-devel -sudo dnf install -y java-latest-openjdk-devel -#sudo dnf install -y asio-devel boost-devel openssl-devel - -# Execute all package installation scripts -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -for script in "$SCRIPT_DIR/packages"/*.sh; do - if [ -f "$script" ]; then - "$script" - fi -done - -#install packages ml -#pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 -#pip3 install transformers - -#sudo yum install -y python3-openstackclient s3fs-fuse awscli -#pip install jupyterlab python-swiftclient -#sudo dnf update -y diff --git a/setup/core/packages/install_claude.sh b/setup/core/packages/install_claude.sh deleted file mode 100755 index 99a881d..0000000 --- a/setup/core/packages/install_claude.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -sudo dnf install -y tar -# Install Node.js via nvm and Claude Code -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -nvm install 22 -npm install -g @anthropic-ai/claude-code diff --git a/setup/core/packages/install_rust.sh b/setup/core/packages/install_rust.sh deleted file mode 100755 index 921a533..0000000 --- a/setup/core/packages/install_rust.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Install Rust and Cargo tools -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -echo '[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"' >> ~/.bashrc -source "$HOME/.cargo/env" -cargo install cargo-clone-crate cargo-edit cargo-info evcxr_jupyter bacon du-dust ripgrep bandwhich diff --git a/setup/core/ssh.sh b/setup/core/ssh.sh deleted file mode 100755 index c4454ae..0000000 --- a/setup/core/ssh.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -dnf install -y git - -echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config -echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config -echo "GatewayPorts yes" | sudo tee -a /etc/ssh/sshd_config -echo "AllowAgentForwarding yes" | sudo tee -a /etc/ssh/sshd_config - -git clone https://git.noml.ch/keys/ ~/keys -~/keys/add-ssh-keys.sh -sudo systemctl restart sshd diff --git a/setup/core/tmux.conf b/setup/core/tmux.conf deleted file mode 100644 index f01bf59..0000000 --- a/setup/core/tmux.conf +++ /dev/null @@ -1,11 +0,0 @@ -# Vi mode for copy -setw -g mode-keys vi - -# Mouse selection -set -g mouse on - -# v to start selection, y to yank (like vim) -bind-key -T copy-mode-vi v send-keys -X begin-selection -bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" -bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" -bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" diff --git a/setup/core/tmux.sh b/setup/core/tmux.sh deleted file mode 100755 index 1e5d3db..0000000 --- a/setup/core/tmux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd "$(dirname "${BASH_SOURCE[0]}")" || exit - -cp tmux.conf /etc/tmux.conf diff --git a/setup/core/vim.sh b/setup/core/vim.sh deleted file mode 100755 index bd99a13..0000000 --- a/setup/core/vim.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -cd "$(dirname "${BASH_SOURCE[0]}")" || exit - -VIMRC_PATH="/etc/vimrc" -[ -d /etc/vim ] && VIMRC_PATH="/etc/vim/vimrc" -CLIP_HOST="p.noml.ch" -CLIP_PORT="5023" -CLIP_CMD="openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 ${CLIP_HOST} ${CLIP_PORT}" - -grep -q 'netcat_clipboard' "$VIMRC_PATH" && exit 0 - -cat << EOF >> "$VIMRC_PATH" -augroup netcat_clipboard - au! - au TextYankPost * call system("echo " . shellescape(@") . " | ${CLIP_CMD} >/dev/null 2>&1 &") -augroup END - -" Enable line wrapping -set wrap - -" Optional: Make wrapped lines easier to read by indenting them -set breakindent -set breakindentopt=shift:1 - -syntax on -set mouse=a -set expandtab -set shiftwidth=4 -set softtabstop=4 -set tabstop=4 -set noautoindent -set nosmartindent -filetype plugin indent on - -set laststatus=2 " permanent status bar -set statusline=%F " shows full file path - -if (has("termguicolors")) - set termguicolors -endif - -"colorscheme murphy -colorscheme zellner - -" Ctrl+A: Move to the beginning of the line in INSERT mode -inoremap - -" Ctrl+E: Move to the end of the line in INSERT mode -inoremap - -" Ctrl+A: Move to the beginning of the line in NORMAL mode -nnoremap 0 - -" Ctrl+E: Move to the end of the line in NORMAL mode -nnoremap $ - -set number -setlocal regexpengine=2 -set paste -set foldcolumn=12 - -set noswapfile -autocmd InsertLeave * silent! update - -EOF diff --git a/setup/git/set-global_user.sh b/setup/git/set-global_user.sh deleted file mode 100755 index 30e11eb..0000000 --- a/setup/git/set-global_user.sh +++ /dev/null @@ -1,2 +0,0 @@ -git config --global user.email "hc@email.ch" -git config --global user.name "hc" diff --git a/setup/git/tools/git-ssh-wrapper.sh b/setup/git/tools/git-ssh-wrapper.sh deleted file mode 100755 index dc23334..0000000 --- a/setup/git/tools/git-ssh-wrapper.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -ssh -v -A -o ForwardAgent=yes "$@" diff --git a/setup/git/tools/usefulbutnotthatusefulidkwhattodo b/setup/git/tools/usefulbutnotthatusefulidkwhattodo deleted file mode 100644 index e69de29..0000000 diff --git a/setup/port-forward/persistent-ssh.sh b/setup/port-forward/persistent-ssh.sh deleted file mode 100755 index 36d14dd..0000000 --- a/setup/port-forward/persistent-ssh.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -echo "selinux command is untested. copy paste systemd file if you want" -echo "reboot afterwards(selinux unset, need reboot to take effect, or just do sudo setenforce 0 for temp unset)" -echo "make sure /root/m exists" -echo "remember to change the remote port or host if needed" - -# disable selinux -sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config - -sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service -[Unit] -Description=Persistent SSH Tunnel -After=network.target -StartLimitIntervalSec=0 - -[Service] -Type=simple -ExecStart=/usr/bin/ssh \ - -i /root/m \ - -o "ExitOnForwardFailure=yes" \ - -o "StrictHostKeyChecking=no" \ - -N -R 24:localhost:22 root@p.0nom.ch -Restart=always -RestartSec=10 -RemainAfterExit=no -KillMode=process - -[Install] -WantedBy=multi-user.target -EOF - -sudo chmod 600 /root/m -sudo systemctl daemon-reload -sudo systemctl enable --now ssh-tunnel diff --git a/setup/port-forward/rm_all_ssh_connections.sh b/setup/port-forward/rm_all_ssh_connections.sh deleted file mode 100755 index f19300d..0000000 --- a/setup/port-forward/rm_all_ssh_connections.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -ss -tnp | grep ':22' -ps -ef | grep sshd | grep -v grep | awk '{if($3!=1) print $2}' | xargs kill -#sudo systemctl restart sshd diff --git a/setup/port-forward/ssh-multiport-forward.sh b/setup/port-forward/ssh-multiport-forward.sh deleted file mode 100755 index 40d4ef6..0000000 --- a/setup/port-forward/ssh-multiport-forward.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Check if at least one argument is provided -if [ $# -lt 1 ]; then - echo "Usage: $0 [additional_ports...]" - echo "Example: $0 5 80 443" - exit 1 -fi - -# First argument is the base number for port range -j=$1 -shift # Remove first argument from the list, leaving only additional ports - -HOST="root@p.0nom.ch" - -# Clean management port -echo "cleaning management port..." -ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" -echo "cleaning attempted." - -# Build the SSH command with all port forwards -SSH_CMD="ssh $HOST" - -# Add range-based port forwards (j000-j005) -for i in $(seq ${j}000 ${j}005); do - SSH_CMD+=" -R $i:localhost:$i" -done - -# Add management port forward -SSH_CMD+=" -R ${j}022:localhost:22" - -# Add additional individual port forwards from remaining arguments -for port in "$@"; do - SSH_CMD+=" -R $port:localhost:$port" -done - -# Execute the SSH command -eval $SSH_CMD - -echo "Port forwards are available on:" -echo "- Ports ${j}000-${j}005" -echo "- Management port ${j}022" -if [ $# -gt 0 ]; then - echo "- Additional ports: $@" -fi diff --git a/setup/port-forward/ssh-port-forward.sh b/setup/port-forward/ssh-port-forward.sh deleted file mode 100755 index c4cb0a8..0000000 --- a/setup/port-forward/ssh-port-forward.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# opens 5 ports - -#file will be run from where the user executes the script -j=$1 -HOST="root@p.0nom.ch" - -# get the process holding the specified port and kill it -echo "cleaning management port..." -ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" -echo "cleaning attempted." - -ssh $HOST $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") - -echo "port forward is available on ports ${j}000-${j}005, ssh on ${j}022" - -#ideally port forward from 2 onwards, there seems to be a problem for 1000(or just change all to j001) -#jupyter lab --port=2001 --ip=0.0.0.0 diff --git a/setup/setup.sh b/setup/setup.sh deleted file mode 100755 index f0cf83b..0000000 --- a/setup/setup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd "$SCRIPT_DIR" || exit - -# Shell appearance (only append if not already present) -grep -q 'di=38;5;135' /etc/bashrc || sudo tee -a /etc/bashrc > /dev/null << 'EOF' -LS_COLORS=$LS_COLORS:'di=38;5;135:ex=00;32:' ; export LS_COLORS -PS1='[\[\033[01;32m\]\u\[\033[00m\]@\h \[\033[38;5;135m\]\W\[\033[00m\]]\$ ' -export TERM=xterm-256color -EOF -source /etc/bashrc - -# Timezone -sudo timedatectl set-timezone Asia/Singapore - -# Core setup -sudo bash ./core/ssh.sh || { echo "Failed to configure SSH"; exit 1; } -sudo bash ./core/install-packages.sh || { echo "Failed to install packages"; exit 1; } -sudo bash ./core/vim.sh || { echo "Failed to configure Vim"; exit 1; } -sudo bash ./core/tmux.sh || { echo "Failed to configure Tmux"; exit 1; } -- cgit