Update server.py
Browse files
server.py
CHANGED
|
@@ -96,24 +96,27 @@ def run_command(command):
|
|
| 96 |
subprocess.run(command, check=True, shell=True)
|
| 97 |
except subprocess.CalledProcessError as e:
|
| 98 |
print(f"An error occurred: {e}")
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
run_command(
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
os.system("echo '
|
| 111 |
-
os.system("
|
| 112 |
-
os.system("
|
|
|
|
|
|
|
|
|
|
| 113 |
clear_output()
|
| 114 |
|
| 115 |
|
| 116 |
-
|
| 117 |
from ruamel.yaml import YAML
|
| 118 |
|
| 119 |
# 创建目录并写入 kaggle.json
|
|
|
|
| 96 |
subprocess.run(command, check=True, shell=True)
|
| 97 |
except subprocess.CalledProcessError as e:
|
| 98 |
print(f"An error occurred: {e}")
|
| 99 |
+
def ssh():
|
| 100 |
+
subprocess.run("apt update", check=True, shell=True)
|
| 101 |
+
subprocess.run("apt install openssh-server -y", check=True, shell=True)
|
| 102 |
+
subprocess.run("apt-get install vim -y", check=True, shell=True)
|
| 103 |
+
config_client_cmd = "sudo sed -i '/PasswordAuthentication/s/^#//g' /etc/ssh/ssh_config"
|
| 104 |
+
run_command(config_client_cmd)
|
| 105 |
+
config_server_cmd = "sudo sed -i '/PermitRootLogin prohibit-password/s/prohibit-password/yes/' /etc/ssh/sshd_config"
|
| 106 |
+
run_command(config_server_cmd)
|
| 107 |
+
run_command("systemctl restart ssh")
|
| 108 |
+
os.system("/etc/init.d/ssh restart")
|
| 109 |
+
|
| 110 |
+
os.system("echo 'root:qilan' | sudo chpasswd")
|
| 111 |
+
os.system("echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config")
|
| 112 |
+
os.system("service ssh restart ")
|
| 113 |
+
os.system("export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | tr ':' '\n' | grep -v '/opt/conda/lib' | paste -sd ':') ")
|
| 114 |
+
os.system("pip install ruamel.yaml") # install ruamel.yaml to solve the import issue
|
| 115 |
+
ssh()
|
| 116 |
clear_output()
|
| 117 |
|
| 118 |
|
| 119 |
+
|
| 120 |
from ruamel.yaml import YAML
|
| 121 |
|
| 122 |
# 创建目录并写入 kaggle.json
|