本文整理汇总了Golang中golang.org/x/crypto/ssh.Session.SendRequest方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.SendRequest方法的具体用法?Golang Session.SendRequest怎么用?Golang Session.SendRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/crypto/ssh.Session
的用法示例。
在下文中一共展示了Session.SendRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RequestAgentForwarding
// RequestAgentForwarding sets up agent forwarding for the session.
// ForwardToAgent or ForwardToRemote should be called to route
// the authentication requests.
func RequestAgentForwarding(session *ssh.Session) error {
ok, err := session.SendRequest("[email protected]", true, nil)
if err != nil {
return err
}
if !ok {
return errors.New("forwarding request denied")
}
return nil
}
示例2:
})
Context("when a window change request is received", func() {
type winChangeMsg struct {
Columns uint32
Rows uint32
WidthPx uint32
HeightPx uint32
}
var result []byte
Context("before a pty is allocated", func() {
BeforeEach(func() {
_, err := session.SendRequest("window-change", false, ssh.Marshal(winChangeMsg{
Rows: 50,
Columns: 132,
}))
Expect(err).NotTo(HaveOccurred())
err = session.RequestPty("vt100", 43, 80, ssh.TerminalModes{})
Expect(err).NotTo(HaveOccurred())
result, err = session.Output("stty size")
Expect(err).NotTo(HaveOccurred())
})
It("ignores the request", func() {
Expect(result).To(ContainSubstring("43 80"))
})
})