|
47 | 47 | # Generate new ssh key if length < 4096
|
48 | 48 | if [ "$(ssh-keygen -l -f "$ssh_key" | awk '{print $1}')" -lt 4096 ]
|
49 | 49 | then
|
50 |
| - tue-install-info "Generating new ssh key as length < 4096, you might need to copy the new key to the robots, GitHub, etc." |
51 |
| - generate_ssh="true" |
| 50 | + # Ask user whether the ssh key should be updated |
| 51 | + while true |
| 52 | + do |
| 53 | + exec < /dev/tty |
| 54 | + read -p $"\033[1m[networking]\033[0m: Your ssh key '$ssh_key' is not secure anymore and needs to be updated. If you use this key for git, you will need to update your public key "\ |
| 55 | + "on the hosts. Do you want to update your key? " -n 1 -r |
| 56 | + exec <&- |
| 57 | + echo # (optional) move to a new line |
| 58 | + |
| 59 | + if [[ $REPLY =~ ^[Yy]$ ]] |
| 60 | + then |
| 61 | + tue-install-info "Generating new ssh key as length < 4096, you might need to copy the new key to the robots, GitHub, etc." |
| 62 | + generate_ssh="true" |
| 63 | + break |
| 64 | + fi |
| 65 | + |
| 66 | + if [[ $REPLY =~ ^[Nn]$ ]] |
| 67 | + then |
| 68 | + tue-install-info "Generating new ssh key as length < 4096, you might need to copy the new key to the robots, GitHub, etc." |
| 69 | + break |
| 70 | + fi |
| 71 | + echo -e "\033[1mPlease answer with 'y' or 'n' to continue\033[0m" |
| 72 | + done |
52 | 73 | else
|
53 | 74 | tue-install-debug "ssh key available with length >= 4096"
|
54 | 75 | fi
|
|
61 | 82 | rm -r ${ssh_controlmasters_dir:?}/* 2>/dev/null # close all connections, to prevent any possible weird behaviour
|
62 | 83 | ssh-add # Start using the new key
|
63 | 84 |
|
64 |
| - # prompt for continuing |
65 |
| - while true |
66 |
| - do |
67 |
| - exec < /dev/tty |
68 |
| - read -p $'\033[1m[networking]\033[0m: Your ssh key has been updated. If you use SSH for git, update your public key '\ |
69 |
| -'on the hosts before continuing. Continue? ' -n 1 -r |
70 |
| - exec <&- |
71 |
| - echo # (optional) move to a new line |
72 |
| - if [[ $REPLY =~ ^[Yy]$ ]] |
73 |
| - then |
74 |
| - break |
75 |
| - fi |
76 |
| - echo -e "\033[1mPlease answer with 'y' to continue\033[0m" |
77 |
| - done |
78 | 85 | fi
|
79 | 86 |
|
80 | 87 | # Enable persistent connection multiplexing
|
|
0 commit comments