MCPcopy
hub / github.com/gliderlabs/ssh / Session

Interface Session

session.go:22–85  ·  view source on GitHub ↗

Session provides access to information about an SSH session and methods to read and write to the SSH channel with an embedded Channel interface from crypto/ssh. When Command() returns an empty slice, the user requested a shell. Otherwise the user is performing an exec with those command arguments.

Source from the content-addressed store, hash-verified

20//
21// TODO: Signals
22type Session interface {
23 gossh.Channel
24
25 // User returns the username used when establishing the SSH connection.
26 User() string
27
28 // RemoteAddr returns the net.Addr of the client side of the connection.
29 RemoteAddr() net.Addr
30
31 // LocalAddr returns the net.Addr of the server side of the connection.
32 LocalAddr() net.Addr
33
34 // Environ returns a copy of strings representing the environment set by the
35 // user for this session, in the form "key=value".
36 Environ() []string
37
38 // Exit sends an exit status and then closes the session.
39 Exit(code int) error
40
41 // Command returns a shell parsed slice of arguments that were provided by the
42 // user. Shell parsing splits the command string according to POSIX shell rules,
43 // which considers quoting not just whitespace.
44 Command() []string
45
46 // RawCommand returns the exact command that was provided by the user.
47 RawCommand() string
48
49 // Subsystem returns the subsystem requested by the user.
50 Subsystem() string
51
52 // PublicKey returns the PublicKey used to authenticate. If a public key was not
53 // used it will return nil.
54 PublicKey() PublicKey
55
56 // Context returns the connection's context. The returned context is always
57 // non-nil and holds the same data as the Context passed into auth
58 // handlers and callbacks.
59 //
60 // The context is canceled when the client's connection closes or I/O
61 // operation fails.
62 Context() Context
63
64 // Permissions returns a copy of the Permissions object that was available for
65 // setup in the auth handlers via the Context.
66 Permissions() Permissions
67
68 // Pty returns PTY information, a channel of window size changes, and a boolean
69 // of whether or not a PTY was accepted for this session.
70 Pty() (Pty, <-chan Window, bool)
71
72 // Signals registers a channel to receive signals sent from the client. The
73 // channel must handle signal sends or it will block the SSH request loop.
74 // Registering nil will unregister the channel from signal sends. During the
75 // time no channel is registered signals are buffered up to a reasonable amount.
76 // If there are buffered signals when a channel is registered, they will be
77 // sent in order on the channel immediately after registering.
78 Signals(c chan<- Signal)
79

Callers 33

TestPasswordAuthFunction · 0.65
TestUserFunction · 0.65
UserMethod · 0.65
mainFunction · 0.65
mainFunction · 0.65
mainFunction · 0.65
HandleSSHRequestMethod · 0.65
RemoteAddrMethod · 0.65
LocalAddrMethod · 0.65
mainFunction · 0.65
mainFunction · 0.65

Implementers 1

sessionsession.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…