Skip to content

Commit 8931be6

Browse files
committed
Remove unused SSH server test scripts and files, add IDisposableAnalyzers package, improve docker workflow with --build flag, document session/socket timeouts, enhance native library path handling, and introduce performance/stress-testing documentation.
1 parent 2df601f commit 8931be6

File tree

19 files changed

+785
-178
lines changed

19 files changed

+785
-178
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: Start Docker Compose services
2626
working-directory: ./src/NullOpsDevs.LibSsh.Test
27-
run: docker compose up -d
27+
run: docker compose up --build -d
2828

2929
- name: Setup SSH Agent
3030
run: |

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: Start Docker Compose services
2626
working-directory: ./src/NullOpsDevs.LibSsh.Test
27-
run: docker compose up -d
27+
run: docker compose up --build -d
2828

2929
- name: Setup SSH Agent
3030
run: |

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ A modern, cross-platform .NET library providing managed bindings for libssh2, en
5050
| | Host key type detection | `SshHostKey.Type` ||
5151
| | Microsoft.Extensions.Logging integration | Constructor `ILogger` parameter ||
5252
| | Cross-platform native binaries | Bundled in NuGet package ||
53-
| **Thread Safety** | `SshSession` is *NOT* thread-safe. | - ||
53+
| | Global library cleanup | `LibSsh2.Exit()` ||
54+
| **Thread Safety** | | | |
55+
| | `SshSession` is *NOT* thread-safe. | - ||
56+
| | Multiple `SshSession`s are supported. | - ||
5457

5558

5659
## Installation
57.3 KB
Loading

docs/Writerside/main.tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@
2323
<toc-element topic="algorithm-preferences.md"/>
2424
<toc-element topic="advanced-terminal-control.md"/>
2525
</toc-element>
26+
<toc-element toc-title="Advanced">
27+
<toc-element topic="performance-and-reliability.md"/>
28+
</toc-element>
29+
<toc-element toc-title="Development">
30+
<toc-element topic="running-tests-locally.md"/>
31+
</toc-element>
2632
</instance-profile>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Performance and Reliability
2+
3+
## Stress Testing
4+
5+
A local stress test was conducted with 2,000 parallel SSH connections to a Docker container on an AMD Ryzen 9 5900X system, completing in 7,921ms.
6+
7+
### Test Environment
8+
9+
**Docker Compose Configuration** (`docker-compose.yml`):
10+
11+
```yaml
12+
services:
13+
ssh-server:
14+
build:
15+
context: ./docker
16+
dockerfile: Dockerfile
17+
container_name: libssh-test-server
18+
hostname: ssh-test
19+
network_mode: "host"
20+
restart: unless-stopped
21+
ulimits:
22+
nofile:
23+
soft: 65536
24+
hard: 65536
25+
nproc:
26+
soft: 32768
27+
hard: 32768
28+
healthcheck:
29+
test: ["CMD", "nc", "-z", "localhost", "2222"]
30+
interval: 5s
31+
timeout: 3s
32+
retries: 10
33+
```
34+
35+
**Dockerfile**:
36+
37+
```Docker
38+
FROM alpine:latest
39+
40+
# Install OpenSSH server
41+
RUN apk add --no-cache openssh-server openssh-keygen
42+
43+
# Create user
44+
RUN adduser -D -s /bin/sh user && \
45+
echo "user:12345" | chpasswd
46+
47+
# Setup SSH directories
48+
RUN mkdir -p /run/sshd /home/user/.ssh && \
49+
chmod 700 /home/user/.ssh && \
50+
chown -R user:user /home/user/.ssh
51+
52+
# Generate host keys
53+
RUN ssh-keygen -A
54+
55+
# Create sshd_config with high limits
56+
RUN echo 'Port 2222' > /etc/ssh/sshd_config && \
57+
echo 'PermitRootLogin no' >> /etc/ssh/sshd_config && \
58+
echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config && \
59+
echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config && \
60+
echo 'AuthorizedKeysFile /home/user/.ssh/authorized_keys' >> /etc/ssh/sshd_config && \
61+
echo 'MaxStartups 1000:30:2000' >> /etc/ssh/sshd_config && \
62+
echo 'MaxSessions 1000' >> /etc/ssh/sshd_config && \
63+
echo 'LoginGraceTime 30' >> /etc/ssh/sshd_config && \
64+
echo 'ClientAliveInterval 30' >> /etc/ssh/sshd_config && \
65+
echo 'ClientAliveCountMax 3' >> /etc/ssh/sshd_config && \
66+
echo 'UseDNS no' >> /etc/ssh/sshd_config && \
67+
echo 'MaxAuthTries 10' >> /etc/ssh/sshd_config
68+
69+
# Create test files directory and generate test files
70+
RUN mkdir -p /test-files && \
71+
echo "Small test file content" > /test-files/small.txt && \
72+
dd if=/dev/urandom of=/test-files/medium.bin bs=1024 count=1024 2>/dev/null && \
73+
dd if=/dev/urandom of=/test-files/large.dat bs=1024 count=10240 2>/dev/null && \
74+
chmod 644 /test-files/*
75+
76+
# Copy SSH keys
77+
COPY test-keys/*.pub /tmp/keys/
78+
RUN cat /tmp/keys/*.pub > /home/user/.ssh/authorized_keys 2>/dev/null || true && \
79+
chmod 600 /home/user/.ssh/authorized_keys && \
80+
chown user:user /home/user/.ssh/authorized_keys && \
81+
rm -rf /tmp/keys
82+
83+
EXPOSE 2222
84+
85+
# Start sshd in foreground
86+
CMD ["/usr/sbin/sshd", "-D", "-e"]
87+
```
88+
89+
### Memory Profile
90+
91+
![Memory Usage During Stress Test](memory_in_peak.png)
92+
93+
The memory profile shows stable behavior with no memory leaks. Memory peaked at ~320MB during the 2,000 parallel connections and was automatically reclaimed by .NET garbage collection afterward.
94+
95+
## See Also
96+
97+
- [Session Lifecycle](session-lifecycle.md) - Proper session management
98+
- [Session Timeouts](session-timeouts.md) - Configuring timeouts
99+
- [Keeping Connection Alive](keeping-connection-alive.md) - Keepalive configuration
100+
- [Error Handling](error-handling.md) - Handling errors gracefully

0 commit comments

Comments
 (0)