This project consists of a server and a client written in Go that allow remote command execution over a TLS-encrypted connection. The server sends commands to the client, and the client executes them locally before sending back the results.
- Secure communication using TLS encryption.
- Executes commands remotely on the client machine.
- Sends multi-line command output back to the server.
- Supports Linux/macOS (for Windows, adjust shell execution accordingly).
Before running the server and client, you need to generate a TLS certificate.
Run the following command to generate a self-signed certificate:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodesThis will generate:
cert.pem- TLS certificate.key.pem- Private key.
Ensure that both the server and client have access to these files.
git clone https://github.com/your-repo/remote-command-tls.git
cd remote-command-tlsgo build -o server server.go
go build -o client client.goRun the server on the host machine:
./serverRun the client on the remote machine (or another terminal):
./clientOnce the client is connected, type any command in the server terminal, and it will execute on the client machine. The result will be sent back to the server.
Example commands:
ls -la
ps aux
df -h- Listens on port 8080 over a TLS-encrypted connection.
- Waits for client connection.
- Sends commands to the client.
- Receives and prints command output from the client.
- Connects to the server over TLS.
- Waits for commands.
- Executes commands locally.
- Sends the output (including multi-line responses) back to the server.
- This implementation disables certificate verification on the client (
InsecureSkipVerify: true).- This should be replaced with proper certificate verification in a production environment.
- Using self-signed certificates is acceptable for local use, but a valid CA-signed certificate is recommended for real-world deployment.
- Ensure
cert.pemandkey.pemare in the same directory asserver.go.
- Ensure the server is running before starting the client.
- Check firewall settings to allow connections on port 8080.
- Ensure the command exists on the client machine.
- Try running it manually on the client before executing remotely.
This project is licensed under the MIT License. Feel free to modify and use it in your own projects.