Skip to content

Commit 16db5a9

Browse files
committed
Merge pull request kubernetes#8621 from MCyprien/util-verify-prereqs
ubuntu cluster utils.sh verify-ssh-prereqs
2 parents 7b9dbbf + 36b2f2d commit 16db5a9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

cluster/ubuntu/util.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,24 @@ function setClusterInfo() {
7777

7878
# Verify ssh prereqs
7979
function verify-prereqs {
80-
# Expect at least one identity to be available.
80+
local rc
81+
82+
rc=0
83+
ssh-add -L 1> /dev/null 2> /dev/null || rc="$?"
84+
# "Could not open a connection to your authentication agent."
85+
if [[ "${rc}" -eq 2 ]]; then
86+
eval "$(ssh-agent)" > /dev/null
87+
trap-add "kill ${SSH_AGENT_PID}" EXIT
88+
fi
89+
90+
rc=0
91+
ssh-add -L 1> /dev/null 2> /dev/null || rc="$?"
92+
# "The agent has no identities."
93+
if [[ "${rc}" -eq 1 ]]; then
94+
# Try adding one of the default identities, with or without passphrase.
95+
ssh-add || true
96+
fi
97+
# Expect at least one identity to be available.
8198
if ! ssh-add -L 1> /dev/null 2> /dev/null; then
8299
echo "Could not find or add an SSH identity."
83100
echo "Please start ssh-agent, add your identity, and retry."

0 commit comments

Comments
 (0)