Merge "Add script for ssh forwarding configuration"
diff --git a/tools/ssh_config/local_config_template.txt b/tools/ssh_config/local_config_template.txt
new file mode 100644
index 0000000..722c07d0
--- /dev/null
+++ b/tools/ssh_config/local_config_template.txt
@@ -0,0 +1,145 @@
+# Host for connecting to the build server
+Host frc971
+    HostName build.frc971.org
+    User {{username}}
+    Port 2222
+    IdentityFile ~/.ssh/{{identity_file}}
+    LocalForward 9971 127.0.0.1:3389
+
+# Hosts for connecting to specific RoboRIOs
+Host roborio
+   HostName 10.9.71.2
+   User admin
+
+Host practice-roborio
+   HostName 10.99.71.2
+   User admin
+
+Host third-roborio
+   HostName 10.89.71.2
+   User admin
+
+# Hosts for connecting to Raspberry Pis
+Host pi1
+   HostName 10.9.71.101
+   User pi
+
+Host pi2
+   HostName 10.9.71.102
+   User pi
+
+Host pi3
+   HostName 10.9.71.103
+   User pi
+
+Host pi4
+   HostName 10.9.71.104
+   User pi
+
+Host pi5
+   HostName 10.9.71.105
+   User pi
+
+Host pi6
+   HostName 10.9.71.106
+   User pi
+
+# Hosts for connecting to practice Raspberry Pis
+Host practice-pi1
+   HostName 10.99.71.101
+   User pi
+
+Host practice-pi2
+   HostName 10.99.71.102
+   User pi
+
+Host practice-pi3
+   HostName 10.99.71.103
+   User pi
+
+Host practice-pi4
+   HostName 10.99.71.104
+   User pi
+
+Host practice-pi5
+   HostName 10.99.71.105
+   User pi
+
+Host practice-pi6
+   HostName 10.99.71.106
+   User pi
+
+# Hosts for connecting to Box of Pi's
+Host box-pi1
+   HostName 10.79.71.101
+   User pi
+
+Host box-pi2
+   HostName 10.79.71.102
+   User pi
+
+Host box-pi3
+   HostName 10.79.71.103
+   User pi
+
+Host box-pi4
+   HostName 10.79.71.104
+   User pi
+
+Host box-pi5
+   HostName 10.79.71.105
+   User pi
+
+Host box-pi6
+   HostName 10.79.71.106
+   User pi
+
+Host frc971-roborio
+   HostName build.frc971.org
+   Port 2222
+   User {{username}}
+   IdentityFile ~/.ssh/{{identity_file}}
+   ForwardAgent yes
+   RemoteForward 10999 10.9.71.2:22
+   RemoteForward 10998 10.9.71.101:22
+   RemoteForward 10997 10.9.71.102:22
+   RemoteForward 10996 10.9.71.103:22
+   RemoteForward 10995 10.9.71.104:22
+   RemoteForward 10994 10.9.71.105:22
+   RemoteForward 10993 10.9.71.106:22
+
+Host frc971-practice-roborio
+   HostName build.frc971.org
+   Port 2222
+   User {{username}}
+   IdentityFile ~/.ssh/{{identity_file}}
+   ForwardAgent yes
+   RemoteForward 10989 10.99.71.2:22
+   RemoteForward 10988 10.99.71.101:22
+   RemoteForward 10987 10.99.71.102:22
+   RemoteForward 10986 10.99.71.103:22
+   RemoteForward 10985 10.99.71.104:22
+   RemoteForward 10984 10.99.71.105:22
+   RemoteForward 10983 10.99.71.106:22
+
+Host frc971-third-roborio
+   HostName build.frc971.org
+   Port 2222
+   IdentityFile ~/.ssh/{{identity_file}}
+   User {{username}}
+   ForwardAgent yes
+   RemoteForward 10979 10.89.71.2:22
+
+Host frc971-box-roborio
+   HostName build.frc971.org
+   Port 2222
+   User {{username}}
+   IdentityFile ~/.ssh/{{identity_file}}
+   ForwardAgent yes
+   RemoteForward 10979 10.79.71.2:22
+   RemoteForward 10978 10.79.71.101:22
+   RemoteForward 10977 10.79.71.102:22
+   RemoteForward 10976 10.79.71.103:22
+   RemoteForward 10975 10.79.71.104:22
+   RemoteForward 10974 10.79.71.105:22
+   RemoteForward 10973 10.79.71.106:22
diff --git a/tools/ssh_config/remote_config_template.txt b/tools/ssh_config/remote_config_template.txt
new file mode 100644
index 0000000..3bbd9f2
--- /dev/null
+++ b/tools/ssh_config/remote_config_template.txt
@@ -0,0 +1,111 @@
+host roborio
+  User admin
+  HostName localhost
+  Port 10999
+  StrictHostKeyChecking no
+
+host practice-roborio
+  User admin
+  HostName localhost
+  Port 10989
+  StrictHostKeyChecking no
+
+host third-roborio
+  User admin
+  HostName localhost
+  Port 10979
+  StrictHostKeyChecking no
+
+host pi1
+  User pi
+  HostName localhost
+  Port 10998
+  IdentityFile ~/.ssh/{{identity_file}}
+host pi2
+  User pi
+  HostName localhost
+  Port 10997
+  IdentityFile ~/.ssh/{{identity_file}}
+host pi3
+  User pi
+  HostName localhost
+  Port 10996
+  IdentityFile ~/.ssh/{{identity_file}}
+host pi4
+  User pi
+  HostName localhost
+  Port 10995
+  IdentityFile ~/.ssh/{{identity_file}}
+host pi5
+  User pi
+  HostName localhost
+  Port 10994
+  IdentityFile ~/.ssh/{{identity_file}}
+host pi6
+  User pi
+  HostName localhost
+  Port 10993
+  IdentityFile ~/.ssh/{{identity_file}}
+
+host practice-pi1
+  User pi
+  HostName localhost
+  Port 10988
+  IdentityFile ~/.ssh/{{identity_file}}
+host practice-pi2
+  User pi
+  HostName localhost
+  Port 10987
+  IdentityFile ~/.ssh/{{identity_file}}
+host practice-pi3
+  User pi
+  HostName localhost
+  Port 10986
+  IdentityFile ~/.ssh/{{identity_file}}
+host practice-pi4
+  User pi
+  HostName localhost
+  Port 10985
+  IdentityFile ~/.ssh/{{identity_file}}
+host practice-pi6
+  User pi
+  HostName localhost
+  Port 10984
+  IdentityFile ~/.ssh/{{identity_file}}
+host practice-pi5
+  User pi
+  HostName localhost
+  Port 10983
+  IdentityFile ~/.ssh/{{identity_file}}
+
+host box-pi1
+  User pi
+  HostName localhost
+  Port 10978
+  IdentityFile ~/.ssh/{{identity_file}}
+host box-pi2
+  User pi
+  HostName localhost
+  Port 10977
+  IdentityFile ~/.ssh/{{identity_file}}
+host box-pi3
+  User pi
+  HostName localhost
+  Port 10976
+  IdentityFile ~/.ssh/{{identity_file}}
+host box-pi4
+  User pi
+  HostName localhost
+  Port 10975
+  IdentityFile ~/.ssh/{{identity_file}}
+host box-pi6
+  User pi
+  HostName localhost
+  Port 10974
+  IdentityFile ~/.ssh/{{identity_file}}
+host box-pi5
+  User pi
+  HostName localhost
+  Port 10973
+  IdentityFile ~/.ssh/{{identity_file}}
+  
\ No newline at end of file
diff --git a/tools/ssh_config/setup_ssh_configs.sh b/tools/ssh_config/setup_ssh_configs.sh
new file mode 100644
index 0000000..2c6f089
--- /dev/null
+++ b/tools/ssh_config/setup_ssh_configs.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# This script sets up SSH configuration for tunnel forwarding so you can
+# build and deploy code without having the code locally.
+# It creates or appends to the local SSH config file (~/.ssh/config)
+# and connects to the build server to create or append the remote SSH config.
+# It prompts the user for their SSH username, the name of the local identity file,
+# and the name of the remote identity file.
+
+# Instructions:
+# 1. Run this script locally on your machine.
+# 2. Make the script executable: chmod +x setup_ssh_configs.sh
+# 3. Run the script: ./setup_ssh_configs.sh
+
+# Note: Ensure that the local and remote SSH config template files are 
+# in the same directory as this script.
+
+# TODO: Use jinja for better templating
+# TODO: Use python to also support windows devices.
+
+# Get the script's directory
+script_dir=$(dirname "$(realpath "$0")")
+
+# Prompt for user input
+read -p "Enter your username for SSH connection: " username
+read -p "Enter the name of the local identity file (e.g., id_971_ed25519): " local_identity_file
+read -p "Enter the name of the remote identity file (e.g., id_971_ed25519): " remote_identity_file
+
+local_ssh_config_template="$script_dir/local_config_template.txt"
+remote_ssh_config_template="$script_dir/remote_config_template.txt"
+
+
+local_ssh_config_content=$(cat "$local_ssh_config_template" | sed -e "s/{{username}}/$username/g" -e "s/{{identity_file}}/$local_identity_file/g")
+local_ssh_config="$HOME/.ssh/config"
+
+# Check if the local SSH config file already exists
+if [ -f "$local_ssh_config" ]; then
+    # Append
+    echo "$local_ssh_config_content" >> "$local_ssh_config"
+else
+    echo "$local_ssh_config_content" > "$local_ssh_config"
+    chmod 600 "$local_ssh_config"
+fi
+
+remote_ssh_config_content=$(cat "$remote_ssh_config_template" | sed -e "s/{{username}}/$username/g" -e "s/{{identity_file}}/$remote_identity_file/g")
+remote_ssh_config="~/.ssh/config"
+
+ssh "frc971" "echo '$remote_ssh_config_content' >> $remote_ssh_config"
+
+echo "SSH configuration for tunnel forwarding has been set up locally and on the build server."