Skip to content

Commit 43d69a4

Browse files
committed
docs: document integration, development, CI/CD, and security practices
- Add a comprehensive guide for Claude Code integration, covering project architecture, main types, key methods, authentication, proxy support, and configuration patterns - Document development commands for testing, formatting, linting, and SSH test server setup - Detail CI/CD procedures, including testing environment, workflows, and code quality tools - Provide usage examples and dependency list - Summarize security features and configuration options Signed-off-by: appleboy <appleboy.tw@gmail.com>
1 parent c1c2fce commit 43d69a4

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

CLAUDE.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
easyssh-proxy is a Go library that provides a simple SSH client implementation with support for SSH tunneling/proxy connections. It's forked from the original easyssh project with additional features for proxy connections, timeout handling, and secure key management.
8+
9+
## Core Architecture
10+
11+
### Main Types
12+
13+
- **MakeConfig**: Primary configuration struct containing SSH connection parameters (user, server, keys, timeouts, proxy settings)
14+
- **DefaultConfig**: Configuration struct used for SSH proxy/jumphost connections
15+
- Both structs share similar fields but MakeConfig includes additional proxy capabilities
16+
17+
### Key Methods
18+
19+
- `Connect()`: Establishes SSH session and client connection
20+
- `Run()`: Executes single command and returns output
21+
- `Stream()`: Executes command with real-time streaming output via channels
22+
- `Scp()`: Copies files to remote server
23+
- `WriteFile()`: Writes content from io.Reader to remote file
24+
25+
### Authentication Support
26+
27+
- Password authentication
28+
- Private key files (with optional passphrase)
29+
- Raw private key content (embedded in code)
30+
- SSH agent integration
31+
- Custom cipher and key exchange algorithms
32+
33+
### Proxy/Jumphost Architecture
34+
35+
The library supports SSH proxy connections where traffic is tunneled through an intermediate server:
36+
37+
```text
38+
Client -> Jumphost -> Target Server
39+
```
40+
41+
The `Proxy` field in MakeConfig uses DefaultConfig to define the jumphost connection parameters.
42+
43+
## Development Commands
44+
45+
### Testing
46+
47+
```bash
48+
make test # Run all tests with coverage
49+
go test -v ./... # Run tests verbose
50+
```
51+
52+
### Code Quality
53+
54+
```bash
55+
make fmt # Format code using gofumpt
56+
make vet # Run go vet
57+
```
58+
59+
### SSH Test Server Setup
60+
61+
```bash
62+
make ssh-server # Setup local SSH test server (Alpine Linux)
63+
```
64+
65+
### Linting
66+
67+
The project uses golangci-lint via GitHub Actions. No local lint command is defined in the Makefile.
68+
69+
## Testing Infrastructure
70+
71+
### Test Environment
72+
73+
- Uses Alpine Linux container with SSH server setup
74+
- Creates test users: `drone-scp` and `root`
75+
- SSH keys located in `tests/.ssh/` directory
76+
- Test files in `tests/` include sample data and configuration
77+
78+
### CI/CD
79+
80+
- GitHub Actions workflow in `.github/workflows/testing.yml`
81+
- Runs tests in Go 1.23 Alpine container
82+
- Includes golangci-lint for code quality
83+
- Codecov integration for coverage reporting
84+
85+
## Code Patterns
86+
87+
### Configuration Pattern
88+
89+
```go
90+
ssh := &easyssh.MakeConfig{
91+
User: "username",
92+
Server: "hostname",
93+
KeyPath: "/path/to/key",
94+
Port: "22",
95+
Timeout: 60 * time.Second,
96+
}
97+
```
98+
99+
### Proxy Configuration
100+
101+
```go
102+
ssh := &easyssh.MakeConfig{
103+
// ... main server config
104+
Proxy: easyssh.DefaultConfig{
105+
// ... jumphost config
106+
},
107+
}
108+
```
109+
110+
### Error Handling
111+
112+
Functions return multiple values following Go conventions:
113+
114+
- `Run()`: (stdout, stderr, isTimeout, error)
115+
- `Stream()`: (stdoutChan, stderrChan, doneChan, errChan, error)
116+
117+
## Example Usage
118+
119+
Comprehensive examples are available in `_examples/` directory:
120+
121+
- `ssh/`: Basic command execution
122+
- `scp/`: File copying
123+
- `proxy/`: SSH tunneling through jumphost
124+
- `stream/`: Real-time command output streaming
125+
- `writeFile/`: Writing content to remote files
126+
127+
## Dependencies
128+
129+
- `golang.org/x/crypto/ssh`: Core SSH protocol implementation
130+
- `github.com/ScaleFT/sshkeys`: Enhanced private key parsing with passphrase support
131+
- `github.com/stretchr/testify`: Testing framework
132+
133+
## Security Considerations
134+
135+
- Supports both secure and insecure cipher configurations
136+
- `UseInsecureCipher` flag enables legacy/weak ciphers when needed
137+
- Fingerprint verification available for enhanced security
138+
- Private keys can be embedded as strings or loaded from files

0 commit comments

Comments
 (0)