-
Notifications
You must be signed in to change notification settings - Fork 4
/
doc.go
56 lines (37 loc) · 1.4 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Package easyssh provides a simple wrapper around the standard SSH library. Designed to be like net/http but for ssh.
Both server and client implementations are provided.
Creating a client is similar to creating a normal ssh client
client, err := easyssh.Dial("tcp", "localhost:2022", config)
if err != nil {
// Handle error
}
defer client.Close()
Once a client is created, you can do a number of things with it:
Local Port Forwarding
err = client.LocalForward("localhost:8000", "localhost:6060")
if err != nil {
// Handle error
}
Remote Port Forwarding
err = client.RemoteForward("localhost:8000", "localhost:6060")
if err != nil {
// Handle error
}
Create a session - used for executing remote commands or getting a remote shell
session, err := client.NewSession()
if err != nil {
// Handle error
}
out, err := session.Output("whoami")
if err != nil {
// Handle error
}
Getting started with an SSH server is easy with easyssh
easyssh.HandleChannel(easyssh.SessionRequest, easyssh.SessionHandler())
easyssh.HandleChannel(easyssh.DirectForwardRequest, easyssh.DirectPortForwardHandler())
easyssh.HandleRequestFunc(easyssh.RemoteForwardRequest, easyssh.TCPIPForwardRequest)
easyssh.ListenAndServe(":2022", sshServerConfig, nil)
There are a lot of layers of ssh communication, and easyssh makes it easy to control at the level desired.
*/
package easyssh