as_root-artix_enable_sshd.sh 704 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. #pacman -S openssh openssh-openrc
  7. #rc-update add sshd default
  8. #rc-service sshd start
  9. pacman -S openssh openssh-dinit
  10. dinitctl enable sshd
  11. dinitctl start sshd
  12. cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
  13. cat /etc/ssh/sshd_config | sed -e "s/#PermitRootLogin yes/PermitRootLogin no/g" | tee /etc/ssh/sshd_config.new
  14. cat /etc/ssh/sshd_config | sed -e "s/#PermitUserEnvironment no/PermitUserEnvironment yes/g" | tee /etc/ssh/sshd_config.new
  15. mv /etc/ssh/sshd_config.new /etc/ssh/sshd_config
  16. read -rp "Enter user name: " username
  17. echo "AllowUsers ${username}" >> /etc/ssh/sshd_config
  18. #rc-service sshd restart
  19. dinitctl restart sshd