Skip to content

Instantly share code, notes, and snippets.

@matthiasbalke
Created March 21, 2019 08:12
Show Gist options
  • Save matthiasbalke/f0abe1e6c18704f086389009075c645e to your computer and use it in GitHub Desktop.
Save matthiasbalke/f0abe1e6c18704f086389009075c645e to your computer and use it in GitHub Desktop.
add ssh key non-interactive using expect
#!/usr/bin/expect -f
# https://unix.stackexchange.com/a/90869/91094
spawn ssh-add /home/user/.ssh/id_rsa
expect "Enter passphrase for /home/user/.ssh/id_rsa:"
send "passphrase\n";
expect "Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)"
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment