diff options
| -rw-r--r-- | port-forward/ssh-port-forward.sh | 3 | ||||
| -rwxr-xr-x | setup.sh | 24 |
2 files changed, 20 insertions, 7 deletions
diff --git a/port-forward/ssh-port-forward.sh b/port-forward/ssh-port-forward.sh index 45f7a18..748c161 100644 --- a/port-forward/ssh-port-forward.sh +++ b/port-forward/ssh-port-forward.sh | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | #file will be run from where the user executes the script | ||
| 3 | j=$1 | 4 | j=$1 |
| 4 | HOST="p.0nom.ch" | 5 | HOST="p.0nom.ch" |
| 5 | KEY_FILE="m" | 6 | KEY_FILE="m" |
| @@ -9,6 +10,6 @@ echo "cleaning management port..." | |||
| 9 | ssh -i "$KEY_FILE" "$HOST" "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" | 10 | ssh -i "$KEY_FILE" "$HOST" "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" |
| 10 | echo "cleaning attempted." | 11 | echo "cleaning attempted." |
| 11 | 12 | ||
| 12 | ssh -i m sg1.0nom.ch $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") | 13 | ssh -i $KEY_FILE $HOST $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") |
| 13 | 14 | ||
| 14 | #seperate all the files | 15 | #seperate all the files |
| @@ -1,18 +1,27 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | curl -L public.0nom.ch/pubkeys >> ~/.ssh/authorized_keys | ||
| 4 | echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config | 3 | echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config |
| 5 | echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config | 4 | echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config |
| 6 | echo "GatewayPorts yes" | sudo tee -a /etc/ssh/sshd_config | 5 | echo "GatewayPorts yes" | sudo tee -a /etc/ssh/sshd_config |
| 7 | 6 | ||
| 7 | sudo dnf install -y git | ||
| 8 | git clone https://git.0nom.ch/keys ~/ | ||
| 9 | mkdir -p "~/.ssh" | ||
| 10 | touch "~/.ssh/authorized_keys" | ||
| 11 | find "~/keys" -name "*.pub" -type f -print0 | while IFS= read -r -d '' file; do | ||
| 12 | echo "Adding key from file: $file" | ||
| 13 | cat "$file" >> "~/.ssh/authorized_keys" | ||
| 14 | echo "" >> "~/.ssh/authorized_keys" # Add a newline after each key | ||
| 15 | done | ||
| 16 | |||
| 8 | #install packages | 17 | #install packages |
| 9 | sudo dnf install -y epel-release dnf-utils | 18 | sudo dnf install -y epel-release dnf-utils |
| 10 | sudo dnf install -y nc autossh tmux htop tar bmon gzip tree wget curl mlocate nano vim unzip net-tools git python3 python3-pip make wireguard-tools iptables usbutils yum | 19 | sudo dnf install -y nc openssl autossh tmux htop tar bmon gzip tree wget curl mlocate nano vim unzip net-tools git python3 python3-pip make wireguard-tools usbutils yum |
| 11 | #sudo yum install -y python3-openstackclient s3fs-fuse awscli | 20 | #sudo yum install -y python3-openstackclient s3fs-fuse awscli |
| 12 | #pip install jupyterlab python-swiftclient | 21 | #pip install jupyterlab python-swiftclient |
| 13 | sudo dnf update -y | 22 | sudo dnf update -y |
| 14 | 23 | ||
| 15 | cat << EOF > /etc/vimrc | 24 | cat << EOF >> /etc/vimrc |
| 16 | augroup netcat_clipboard | 25 | augroup netcat_clipboard |
| 17 | au! | 26 | au! |
| 18 | au TextYankPost * call system("openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.0nom.ch 5023", @") | 27 | au TextYankPost * call system("openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.0nom.ch 5023", @") |
| @@ -23,12 +32,15 @@ set wrap | |||
| 23 | 32 | ||
| 24 | " Optional: Make wrapped lines easier to read by indenting them | 33 | " Optional: Make wrapped lines easier to read by indenting them |
| 25 | set breakindent | 34 | set breakindent |
| 26 | set breakindentopt=shift:2 | 35 | set breakindentopt=shift:3 |
| 27 | 36 | ||
| 28 | set list | ||
| 29 | set listchars=tab:>- | ||
| 30 | set autoindent | 37 | set autoindent |
| 31 | set number | 38 | set number |
| 39 | set mouse=a | ||
| 40 | set expandtab | ||
| 41 | set shiftwidth=2 | ||
| 42 | set softtabstop=2 | ||
| 43 | set tabstop=2 | ||
| 32 | EOF | 44 | EOF |
| 33 | 45 | ||
| 34 | # add check fro each component | 46 | # add check fro each component |
