0

I'm trying to automate some of my personal server setup using Ansible, in order to wipe my disk clean and migrate to Ubuntu 20.04. Part of this process is installing the SSH keys I use for Github access.

The SSH public/secret keys are stored in pass, and I'm able to get those copied over to ~/.ssh/github.pub and ~/.ssh/github just fine. But at this point I'm stuck: if I were doing this by hand, I'd run eval $(ssh-agent -s) to set environment variables, and then run ssh-add ~/.ssh/github. I'm not sure how to accomplish this with Ansible. Searching for Ansible and anything involving SSH produces a lot of results with setting up remote access for Ansible to run on external hosts, and doesn't seem like it'd help in this use case.

Mark LeMoine
  • 201
  • 1
  • 3
  • 7
  • Is your ssh key password-protected? If no, you could probably just use: `ansible-playbook --private-key ~/.ssh/github` If yes, you could run `ssh-agent -a /tmp/ssh.sock` to get the socket and use `SSH_AUTH_SOCK=/tmp/ssh.sock` as an evironment-variable in ansible. – rndmh3ro May 12 '20 at 06:31
  • Well, I'm not actually doing any SSH calls with Ansible, this is just to set up SSH keys so that, once I run this Ansible task, I can then manually later on run `git clone ` and just have it work. – Mark LeMoine May 12 '20 at 20:32
  • I too got fed up manually loading my SSH keys and created an Ansible project to automate it. Not sure it's worthy to be an answer: https://github.com/athajaerel/load_keys – Adam J Richardson Feb 03 '22 at 19:00

0 Answers0