diff options
Diffstat (limited to 'git/set-global_git-ssh-wrapper.sh')
| -rwxr-xr-x | git/set-global_git-ssh-wrapper.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/git/set-global_git-ssh-wrapper.sh b/git/set-global_git-ssh-wrapper.sh new file mode 100755 index 0000000..e851f1b --- /dev/null +++ b/git/set-global_git-ssh-wrapper.sh | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | if ! sudo grep -q "^AllowAgentForwarding yes" /etc/ssh/sshd_config; then | ||
| 4 | echo "AllowAgentForwarding not set. Adding it to sshd_config..." | ||
| 5 | echo "AllowAgentForwarding yes" | sudo tee -a /etc/ssh/sshd_config > /dev/null | ||
| 6 | echo "Added AllowAgentForwarding yes to /etc/ssh/sshd_config" | ||
| 7 | else | ||
| 8 | echo "AllowAgentForwarding is already set to yes in /etc/ssh/sshd_config" | ||
| 9 | fi | ||
| 10 | # this should be enabled on both client and server | ||
| 11 | |||
| 12 | # Get the directory of this script | ||
| 13 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
| 14 | |||
| 15 | # Path to the git-ssh-wrapper.sh | ||
| 16 | WRAPPER_PATH="$SCRIPT_DIR/tools/git-ssh-wrapper.sh" | ||
| 17 | |||
| 18 | # Check if the wrapper script exists | ||
| 19 | if [ ! -f "$WRAPPER_PATH" ]; then | ||
| 20 | echo "Error: git-ssh-wrapper.sh not found at $WRAPPER_PATH" | ||
| 21 | exit 1 | ||
| 22 | fi | ||
| 23 | |||
| 24 | # Make sure the wrapper script is executable | ||
| 25 | chmod +x "$WRAPPER_PATH" | ||
| 26 | |||
| 27 | # Set the global Git SSH command | ||
| 28 | git config --global core.sshCommand "$WRAPPER_PATH" | ||
| 29 | |||
| 30 | echo "Git SSH command has been set to use $WRAPPER_PATH" | ||
| 31 | echo "You can verify this by running: git config --global --get core.sshCommand" | ||
| 32 | |||
| 33 | #ssh-agent bash -c 'ssh-add ~/key && ssh -A -p24 user@code.server' | ||
