aboutsummaryrefslogtreecommitdiff
path: root/ssh/session.go
diff options
context:
space:
mode:
authorChristine Hansmann <chhansmann@gmail.com>2012-06-18 12:11:37 -0400
committerAdam Langley <agl@golang.org>2012-06-18 12:11:37 -0400
commitcde552e05fc46a4051273bcd80956debf3e548bd (patch)
treeefe40cd5d85bd6de1988a24cc13ea8b82282a40c /ssh/session.go
parent929dedf39d9e8e1ffa201091598b681961c04b85 (diff)
downloadgo-x-crypto-cde552e05fc46a4051273bcd80956debf3e548bd.tar.xz
ssh: added RequestSubsystem().
RequestSubsystem requests the association of a subsystem with the ssh session on the remote host. A subsystem is a predefined command that runs in the background when the ssh session is initiated (i.e. sftp). R=golang-dev, agl CC=golang-dev, gustav.paul https://golang.org/cl/6295096
Diffstat (limited to 'ssh/session.go')
-rw-r--r--ssh/session.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/ssh/session.go b/ssh/session.go
index 22f9e91..88a4406 100644
--- a/ssh/session.go
+++ b/ssh/session.go
@@ -85,6 +85,14 @@ type setenvRequest struct {
Value string
}
+// RFC 4254 Section 6.5.
+type subsystemRequestMsg struct {
+ PeersId uint32
+ Request string
+ WantReply bool
+ Subsystem string
+}
+
// Setenv sets an environment variable that will be applied to any
// command executed by Shell or Run.
func (s *Session) Setenv(name, value string) error {
@@ -136,6 +144,21 @@ func (s *Session) RequestPty(term string, h, w int) error {
return s.waitForResponse()
}
+// RequestSubsystem requests the association of a subsystem with the session on the remote host.
+// A subsystem is a predefined command that runs in the background when the ssh session is initiated
+func (s *Session) RequestSubsystem(subsystem string) error {
+ req := subsystemRequestMsg{
+ PeersId: s.remoteId,
+ Request: "subsystem",
+ WantReply: true,
+ Subsystem: subsystem,
+ }
+ if err := s.writePacket(marshal(msgChannelRequest, req)); err != nil {
+ return err
+ }
+ return s.waitForResponse()
+}
+
// RFC 4254 Section 6.9.
type signalMsg struct {
PeersId uint32