Guest User

Untitled

a guest
Dec 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. function ssh-keys () {
  4. if ssh-add -l | grep -q "$1"; then
  5. echo "$1 key is ready"
  6. else
  7. /usr/bin/expect -c "
  8. spawn /usr/bin/ssh-add $1;
  9. expect 'Enter passphrase';
  10. send $2\r;
  11. expect eof;"
  12. fi
  13. }
  14.  
  15. #get passwords from credstash
  16. prod_pass=$(credstash -p prod get prod-key-password)
  17. eng_pass=$(credstash -p dev get eng-key-password)
  18.  
  19. #call function that to add them. example: ssh-keys [path to key] [password]
  20. ssh-keys $HOME/.ssh/production $prod_pass
  21. ssh-keys $HOME/.ssh/engineering $eng_pass
Add Comment
Please, Sign In to add comment