Skip to content

Commit 36b2f2d

Browse files
author
Marc Cyprien
committed
1 parent d3778f5 commit 36b2f2d

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
@@ -75,7 +75,24 @@ function setClusterInfo() {
7575

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

0 commit comments

Comments
 (0)