stored passphrase for ssh key

25 views
Skip to first unread message

Stephen Burke

unread,
Jul 11, 2019, 11:00:52 AM7/11/19
to Ansible Project
Does anyone know a way to store an ssh passphrase during a playbook run? All nodes have the same ssh key/passphrase. I just don't want to type the same passphrase 100 times during the playbook run. Is there any way to do this with passphrases? 

Santha Kumar

unread,
Jul 11, 2019, 11:36:28 AM7/11/19
to ansible...@googlegroups.com
Define a variable to fetch it from file.

On Thu, 11 Jul 2019 at 8:30 PM, Stephen Burke <53op...@gmail.com> wrote:
Does anyone know a way to store an ssh passphrase during a playbook run? All nodes have the same ssh key/passphrase. I just don't want to type the same passphrase 100 times during the playbook run. Is there any way to do this with passphrases? 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0560d800-ebe4-4dd2-9bd7-b8a0f53da9fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Burke

unread,
Jul 11, 2019, 4:16:33 PM7/11/19
to Ansible Project
Figured it out. Add the following to your bash_profile:

# Configure ssh-agent (begin)
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
    echo "Initializing new SSH agent..."
    /usr/bin/ssh-agent |sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add ~/.ssh/$(whoami);
}

# Source SSH settings, if required
if [ -f "${SSH_ENV}" ]; then
    . "${SSH_ENV}" > /dev/null
    ps -ef |grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
      start_agent;
  }
else
    start_agent;
fi
# Configure ssh-agent (end)

Reply all
Reply to author
Forward
0 new messages