I am currently working on a script that does an update via SSH on an remote PC.
The idea is that the host pc sends a command to create a script to the pc I want to update.
Then the pc runs the script and deletes the script afterwards.
The last thing I want to achive is that all this happenes without asking for a password.
I think I got the hardest part done but there is an error I have no idea how to fix.
This is the script:
#!/bin/bash path=$(find -iname update.sh) read -p "Enter IP-Adress: " ip read -p "Enter user number (e.g. 01): " user select connect in Certificate Update Connection do case $connect in "Certificate") ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa isatlab-cli$user@$ip ;; "Update") ssh isatlab-cli$user@$ip ' cat > update.sh << EQF #!/bin/bash campusIT=enp42s0 isatLab=enp43s0 currentKernel=linux55 select action in Kernel System Reboot CampusIT ISAT-Lab do case $action in "Kernel") echo "Updating Kernel" sudo mhwd-kernel -i $currentKernel rmc ;; "System") echo "Updating System" sudo pacman -Syyu echo "Updating complete!" ;; "Reboot") rm ./tempUpdate.sh sudo systemctl reboot ;; "CampusIT") sudo ip link set $campusIT up sudo ip link set $isatLab down echo "Network interface now running." ;; "ISAT-Lab") sudo ip link set $campusIT down sudo ip link set $isatLab up echo "Network interface shut down." ;; *) echo "Invalid entry." break ;; esac done EQF ' ssh isatlab-cli$user@$ip 'chmod +x update.sh' ssh isatlab-cli$user@$ip './update.sh' ssh isatlab-cli$user@$ip 'rm update.sh' ;; "Connection") ssh isatlab-cli$user@$ip ;; *) echo "Invalid entry" break ;; esac done
This is the error:
./update.sh: line 9: syntax error near unexpected token `"Kernel"' ./update.sh: line 9: `"Kernel")'
Note that line 9 in update.sh is line 28 in the orginal script.
I hope someone can help me and explain what I am doing wrong.
Thanks in advanced!