-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_ssh_git.sh
More file actions
33 lines (28 loc) · 764 Bytes
/
Copy pathsetup_ssh_git.sh
File metadata and controls
33 lines (28 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Exit on any error. If something fails, there's no use
# proceeding further because Jenkins might not be able
# to run in that case
set -e
# Prepare ssh keys
# Create it in the user workspace so we can store it
cd ~/webpage_ws
if [ ! -f id_rsa ]; then
ssh-keygen -q -N '' -C '' -f id_rsa
fi
# Copy the ssh key to the ~/.ssh directory
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh
if [ ! -f id_rsa ]; then
cp ~/webpage_ws/id_rsa .
cp ~/webpage_ws/id_rsa.pub .
chmod 600 id_rsa
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
fi
# Start the ssh agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# config git
git config --global user.name 'Jenkins Course'
git config --global user.email 'jenkins@theconstruct.ai'