Added C11 in testing
This commit is contained in:
parent
c1d03dc970
commit
9ee44a1a76
34
Codes/Code-C11.py
Normal file
34
Codes/Code-C11.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import paramiko
|
||||||
|
|
||||||
|
def install_dhcp_server(remote_host, username, password):
|
||||||
|
# Create an SSH client
|
||||||
|
ssh = paramiko.SSHClient()
|
||||||
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Connect to the remote machine
|
||||||
|
ssh.connect(remote_host, username=username, password=password)
|
||||||
|
|
||||||
|
# Update package list
|
||||||
|
stdin, stdout, stderr = ssh.exec_command('sudo apt update')
|
||||||
|
stdout.channel.recv_exit_status() # Wait for the command to complete
|
||||||
|
|
||||||
|
# Install ISC DHCP Server
|
||||||
|
stdin, stdout, stderr = ssh.exec_command('sudo apt install -y isc-dhcp-server')
|
||||||
|
stdout.channel.recv_exit_status() # Wait for the command to complete
|
||||||
|
|
||||||
|
# Optional: you can add more commands to configure the DHCP server here
|
||||||
|
print("DHCP server installed successfully.")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An error occurred: {e}")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
# Close the SSH connection
|
||||||
|
ssh.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
remote_host = "192.168.1.100" # Replace with your remote machine's IP
|
||||||
|
username = "your_username" # Replace with your SSH username
|
||||||
|
password = "your_password" # Replace with your SSH password
|
||||||
|
install_dhcp_server(remote_host, username, password)
|
Loading…
Reference in New Issue
Block a user