File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
_examples/ssh-localforward Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "io"
5
+ "log"
6
+
7
+ "github.com/gliderlabs/ssh"
8
+ )
9
+
10
+ func main () {
11
+ log .Println ("starting ssh server on port 2222..." )
12
+
13
+ server := ssh.Server {
14
+ LocalPortForwardingCallback : ssh .LocalPortForwardingCallback (func (ctx ssh.Context , dhost string , dport uint32 ) bool {
15
+ log .Println ("Accepted forward" , dhost , dport )
16
+ return true
17
+ }),
18
+ Addr : ":2222" ,
19
+ Handler : ssh .Handler (func (s ssh.Session ) {
20
+ io .WriteString (s , "Local forwarding available...\n " )
21
+ select {}
22
+ }),
23
+ ChannelHandlers : map [string ]ssh.ChannelHandler {
24
+ "session" : ssh .DefaultSessionHandler ,
25
+ "direct-tcpip" : ssh .DirectTCPIPHandler ,
26
+ },
27
+ }
28
+
29
+ log .Fatal (server .ListenAndServe ())
30
+ }
You can’t perform that action at this time.
0 commit comments