mirror of
https://github.com/JamesTurland/JimsGarage.git
synced 2024-11-25 01:10:22 +00:00
Update k3s.sh
- added the variable for the ssh config file - check if the file exist - if file exist, look for the StrictHostKeyChecking value and update if needed, otherwise add the line - if file does not exist, create it, change file permissions and add the setting
This commit is contained in:
parent
379113a824
commit
6503c607b1
1 changed files with 28 additions and 2 deletions
|
@ -60,6 +60,9 @@ lbrange=192.168.3.60-192.168.3.80
|
||||||
#ssh certificate name variable
|
#ssh certificate name variable
|
||||||
certName=id_rsa
|
certName=id_rsa
|
||||||
|
|
||||||
|
#ssh config file
|
||||||
|
config_file=~/.ssh/config
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# DO NOT EDIT BELOW #
|
# DO NOT EDIT BELOW #
|
||||||
#############################################
|
#############################################
|
||||||
|
@ -92,8 +95,31 @@ else
|
||||||
echo -e " \033[32;5mKubectl already installed\033[0m"
|
echo -e " \033[32;5mKubectl already installed\033[0m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create SSH Config file to ignore checking (don't use in production!)
|
# Check for SSH config file, create if needed, add/change Strict Host Key Checking (don't use in production!)
|
||||||
sed -i '1s/^/StrictHostKeyChecking no\n/' ~/.ssh/config
|
|
||||||
|
if [ ! -f "$config_file" ]; then
|
||||||
|
# Create the file and add the line
|
||||||
|
echo "StrictHostKeyChecking no" > "$config_file"
|
||||||
|
# Set permissions to read and write only for the owner
|
||||||
|
chmod 600 "$config_file"
|
||||||
|
echo "File created and line added."
|
||||||
|
else
|
||||||
|
# Check if the line exists
|
||||||
|
if grep -q "^StrictHostKeyChecking" "$config_file"; then
|
||||||
|
# Check if the value is not "no"
|
||||||
|
if ! grep -q "^StrictHostKeyChecking no" "$config_file"; then
|
||||||
|
# Replace the existing line
|
||||||
|
sed -i 's/^StrictHostKeyChecking.*/StrictHostKeyChecking no/' "$config_file"
|
||||||
|
echo "Line updated."
|
||||||
|
else
|
||||||
|
echo "Line already set to 'no'."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Add the line to the end of the file
|
||||||
|
echo "StrictHostKeyChecking no" >> "$config_file"
|
||||||
|
echo "Line added."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#add ssh keys for all nodes
|
#add ssh keys for all nodes
|
||||||
for node in "${all[@]}"; do
|
for node in "${all[@]}"; do
|
||||||
|
|
Loading…
Reference in a new issue