Skip to content

Commit 3757d80

Browse files
authoredMar 20, 2025
support proxy banner from upstream (#548)
* remove unused logs * add banner to server password * add updated crypto lib * add test * refactor: clean up whitespace in banner test * fix: update test case name to use underscores for consistency
1 parent af3d258 commit 3757d80

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed
 

‎crypto

‎e2e/banner_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,50 @@ func TestBanner(t *testing.T) {
114114

115115
waitForStdoutContains(stdout, randtext, func(_ string) {
116116
})
117+
118+
t.Run("from_upstream", func(t *testing.T) {
119+
piperaddr, piperport := nextAvailablePiperAddress()
120+
121+
piper, _, _, err := runCmd("/sshpiperd/sshpiperd",
122+
"-p",
123+
piperport,
124+
"/sshpiperd/plugins/fixed",
125+
"--target",
126+
"host-password:2222",
127+
)
128+
129+
if err != nil {
130+
t.Errorf("failed to run sshpiperd: %v", err)
131+
}
132+
133+
defer killCmd(piper)
134+
135+
waitForEndpointReady(piperaddr)
136+
137+
c, stdin, stdout, err := runCmd(
138+
"ssh",
139+
"-v",
140+
"-o",
141+
"StrictHostKeyChecking=no",
142+
"-o",
143+
"UserKnownHostsFile=/dev/null",
144+
"-p",
145+
piperport,
146+
"-l",
147+
"user",
148+
"127.0.0.1",
149+
)
150+
151+
if err != nil {
152+
t.Errorf("failed to ssh to piper, %v", err)
153+
}
154+
155+
defer killCmd(c)
156+
157+
enterPassword(stdin, stdout, "wrongpass")
158+
159+
waitForStdoutContains(stdout, "sshpiper banner from upstream test", func(_ string) {
160+
})
161+
})
117162
})
118163
}

‎e2e/docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
volumes:
1717
- shared:/shared
1818
- ./sshdconfig/no_penalties.conf:/config/sshd/sshd_config.d/no_penalties.conf:ro
19+
- ./sshdconfig/banner.conf:/config/sshd/sshd_config.d/banner.conf:ro
20+
- ./sshdconfig/banner:/tmp/banner:ro
1921
networks:
2022
- default
2123
- netdistract

‎e2e/sshdconfig/banner

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sshpiper banner from upstream test

‎e2e/sshdconfig/banner.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Banner /tmp/banner

‎libplugin/skel.go

-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ func (p *SkelPlugin) PublicKeyCallback(conn ConnMetadata, publicKey []byte) (*Up
212212
return false, err
213213
}
214214

215-
log.Debugf("trusted user ca keys: %v", rest)
216-
217215
var trustedca ssh.PublicKey
218216
for len(rest) > 0 {
219217
trustedca, _, _, rest, err = ssh.ParseAuthorizedKey(rest)

0 commit comments

Comments
 (0)
Failed to load comments.