Documentation
¶
Index ¶
- type Client
- type Session
- func (s *Session) Copy(srcpath, dstpath string) error
- func (s *Session) CopyAs(srcpath, dstpath, user string) error
- func (s *Session) Exists(path string) (bool, error)
- func (s *Session) ExistsAs(path, user string) (bool, error)
- func (s *Session) Mkdir(path string, perm os.FileMode) error
- func (s *Session) MkdirAs(path string, perm os.FileMode, user string) error
- func (s *Session) Move(srcpath, dstpath string) error
- func (s *Session) MoveAs(srcpath, dstpath, user string) error
- func (s *Session) ReadFile(dst io.Writer, filename string) error
- func (s *Session) ReadFileAs(dst io.Writer, filename, user string) error
- func (s *Session) Remove(name string) error
- func (s *Session) RemoveAll(path string) error
- func (s *Session) RemoveAllAs(path, user string) error
- func (s *Session) RemoveAs(name, user string) error
- func (s *Session) WriteFile(filename string, src io.Reader, perm os.FileMode) error
- func (s *Session) WriteFileAs(filename string, src io.Reader, perm os.FileMode, user string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client implements a traditional SSH client that supports shells, subprocesses, TCP port/streamlocal forwarding and tunneled dialing, and file operations.
func (*Client) NewSession ¶
NewSession opens a new Session for this client. (A session is a remote execution of a program, or file operation.)
type Session ¶
Session adds file system operations to golang.org/x/crypto/ssh.Session.
func (*Session) Copy ¶
Copy copies the source path to the destination path, using the semantics of the `cp` command.
func (*Session) CopyAs ¶
CopyAs moves, as the user, the source path to the destination path, using the semantics of the `cp` command.
func (*Session) Mkdir ¶
Mkdir creates a new directory with the specified name and permission bits (before umask).
func (*Session) MkdirAs ¶
MkdirAs creates, as the chosen user, a new directory with the specified name and permission bits (before umask).
func (*Session) Move ¶
Move moves the source path to the destination path, using the semantics of the `mv` command.
func (*Session) MoveAs ¶
MoveAs moves, as the user, the source path to the destination path, using the semantics of the `mv` command.
func (*Session) ReadFile ¶
ReadFile reads the remote file into a stream.
Example ¶
srv := &gliderssh.Server{ Handler: func(s gliderssh.Session) { io.WriteString(s, "sample file") }, } s, cleanup, err := newTestSession(srv, nil) if err != nil { log.Fatalf("error creating session: %s", err) } defer cleanup() var dst bytes.Buffer err = s.ReadFile(&dst, "foo") if err != nil { log.Fatalf("error reading file: %s", err) } fmt.Println(dst.String())
Output: sample file
func (*Session) ReadFileAs ¶
ReadFileAs reads, as the user, the remote file into a stream.
func (*Session) RemoveAll ¶
RemoveAll removes the path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).
func (*Session) RemoveAllAs ¶
RemoveAllAs removes, as the user, the path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).