4
0

olivetin-setup-easy-ssh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. mkdir -p /config/ssh/
  3. SSH_KEY=/config/ssh/id_rsa
  4. echo "Documentation for this script: https://docs.olivetin.app/action-ssh-easy.html"
  5. echo ""
  6. if test -f "$SSH_KEY"; then
  7. echo "Using existing SSH key at $SSH_KEY, not generating a new one"
  8. else
  9. ssh-keygen -f $SSH_KEY -N ''
  10. echo "Your new SSH key has been generated and saved to $SSH_KEY"
  11. fi
  12. echo "To use this SSH key with OliveTin, format your action line like this:"
  13. echo ""
  14. echo "actions:"
  15. echo " - name: My SSH Action"
  16. echo " shell: ssh -F /config/ssh/easy.cfg user@host \"echo 'Hello, world!'\""
  17. echo ""
  18. echo "Note: This config has ssh key checking turned off so you don't have to "
  19. echo "keep approving host keys inside the OliveTin container. This should only"
  20. echo "be used in environments where checking SSH host keys is not important."
  21. echo ""
  22. echo "If validating SSH host keys is important, you should not use this config."
  23. echo ""
  24. cat <<EOF > /config/ssh/easy.cfg
  25. Host *
  26. StrictHostKeyChecking no
  27. UserKnownHostsFile=/dev/null
  28. IdentityFile /config/ssh/id_rsa
  29. EOF
  30. echo "Copy this line into your ~/.ssh/authorized_keys file to allow OliveTin to connect to your server:"
  31. cat /config/ssh/id_rsa.pub