Skip to content

emad-siddiq/simple_ssh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Go SSH Client/Server Implementation

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.

Prerequisites

  • Go 1.16 or later
  • golang.org/x/crypto/ssh package

Project Structure

go-ssh/
├── server/
│   ├── main.go
│   └── id_rsa     # Server private key (will be generated)
├── client/
│   └── main.go
└── README.md

Installation

  1. Clone the repository:
git clone https://github.com/emad-siddiq/simple_ssh
cd simple_ssh
  1. Generate SSH key for the server:
# From the project root directory
ssh-keygen -t rsa -f server/id_rsa

Building

Server

cd server
go build -o ssh-server

Client

cd client
go build -o ssh-client

Running

  1. Start the server:
# If built:
./server/ssh-server

# Or run directly:
cd server
go run main.go
  1. 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>

Default Configuration

  • Server port: 2222
  • Default username: "testuser"
  • Default password: "password123"
  • Server host: localhost

Usage Examples

After connecting with the client, you can run various shell commands:

$ ls -la
$ pwd
$ date
$ echo "Hello, World!"
$ exit    # to close the session

Security Considerations

This implementation is for educational purposes and includes several security compromises:

  1. Uses hardcoded credentials
  2. Uses InsecureIgnoreHostKey in the client
  3. No encryption of sensitive configuration
  4. No rate limiting
  5. No audit logging
  6. 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

License

CC BY 4.0

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0

About

SSH server and client in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages