You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
871 B

  1. #!/bin/bash
  2. if [ ! -d /data/ssh ]; then
  3. mkdir -p /data/ssh
  4. fi
  5. if [ ! -f /data/ssh/ssh_host_ed25519_key ]; then
  6. echo "Generating /data/ssh/ssh_host_ed25519_key..."
  7. ssh-keygen -t ed25519 -b 4096 -f /data/ssh/ssh_host_ed25519_key -N "" > /dev/null
  8. fi
  9. if [ ! -f /data/ssh/ssh_host_rsa_key ]; then
  10. echo "Generating /data/ssh/ssh_host_rsa_key..."
  11. ssh-keygen -t rsa -b 2048 -f /data/ssh/ssh_host_rsa_key -N "" > /dev/null
  12. fi
  13. if [ ! -f /data/ssh/ssh_host_dsa_key ]; then
  14. echo "Generating /data/ssh/ssh_host_dsa_key..."
  15. ssh-keygen -t dsa -f /data/ssh/ssh_host_dsa_key -N "" > /dev/null
  16. fi
  17. if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
  18. echo "Generating /data/ssh/ssh_host_ecdsa_key..."
  19. ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null
  20. fi
  21. chown root:root /data/ssh/*
  22. chmod 0700 /data/ssh
  23. chmod 0600 /data/ssh/*