A simple SSH client and server implementation that supports connections to remote SSH servers like AWS or the bundled local server. It offers remote command execution and interactive shell sessions.
- Go 1.16 or later
golang.org/x/crypto/sshpackage
go-ssh/
├── server/
│ ├── main.go
│ └── id_rsa # Server private key (will be generated)
├── client/
│ └── main.go
└── README.md
- Clone the repository:
git clone https://github.com/emad-siddiq/simple_ssh
cd simple_ssh- Generate SSH key for the server:
# From the project root directory
ssh-keygen -t rsa -f server/id_rsacd server
go build -o ssh-servercd client
go build -o ssh-client- Start the server:
# If built:
./server/ssh-server
# Or run directly:
cd server
go run main.go- In another terminal, start the client:
# If built:
./client/ssh-client -key ~/.ssh/aws.pem -user ubuntu -host <aws-host-url>
# Or run directly:
cd client
go run . -key ~/.ssh/aws.pem -user ubuntu -host <aws-host-url>- Server port: 2222
- Default username: "testuser"
- Default password: "password123"
- Server host: localhost
After connecting with the client, you can run various shell commands:
$ ls -la
$ pwd
$ date
$ echo "Hello, World!"
$ exit # to close the sessionThis implementation is for educational purposes and includes several security compromises:
- Uses hardcoded credentials
- Uses
InsecureIgnoreHostKeyin the client - No encryption of sensitive configuration
- No rate limiting
- No audit logging
- No command sanitization
For production use, one should:
- Implement proper user authentication
- Use proper host key verification
- Implement proper logging
- Add timeout mechanisms
- Add resource limits
- Implement proper error handling
This work is licensed under a Creative Commons Attribution 4.0 International License.
