Documentation ¶
Overview ¶
Package scp handles file uploads and downloads via SCP command. See https://web.archive.org/web/20170215184048/https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works for the high-level protocol overview.
Authoritative source for the protocol is the source code for OpenSSH scp: https://github.com/openssh/openssh-portable/blob/add926dd1bbe3c4db06e27cab8ab0f9a3d00a0c2/scp.c
Index ¶
Constants ¶
const ( // OKByte is SCP OK message bytes OKByte = 0x0 // WarnByte tells that next goes a warning string WarnByte = 0x1 // ErrByte tells that next goes an error string ErrByte = 0x2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command interface { // Execute processes SCP traffic Execute(ch io.ReadWriter) error // GetRemoteShellCmd returns a remote shell command that // has to be executed on the remove server (handled by Teleport) GetRemoteShellCmd() (string, error) }
Command is an API that describes command operations
func CreateCommand ¶
CreateCommand creates and returns a new SCP command with specified configuration.
func CreateDownloadCommand ¶
CreateDownloadCommand configures and returns a command used to download a file
func CreateUploadCommand ¶
CreateUploadCommand configures and returns a command used to upload a file
type Config ¶
type Config struct { // Flags is a set of SCP command line flags Flags Flags // User is a user who runs SCP command User string // AuditLog is AuditLog log AuditLog events.AuditLogSessionStreamer // ProgressWriter is a writer for printing the progress // (used only on the client) ProgressWriter io.Writer // FileSystem is a source file system abstraction for the SCP command FileSystem FileSystem // RemoteLocation is a destination location of the file RemoteLocation string // RunOnServer is low level API flag that indicates that // this command will be run on the server RunOnServer bool // Log optionally specifies the logger Log log.FieldLogger }
Config describes Command configuration settings
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults checks and sets default values
type FileInfo ¶
type FileInfo interface { // IsDir returns true if a file is a directory IsDir() bool // ReadDir returns information of directory files ReadDir() ([]FileInfo, error) // GetName returns a file name GetName() string // GetPath returns a file path GetPath() string // GetModePerm returns file permissions GetModePerm() os.FileMode // GetSize returns file size GetSize() int64 // GetModTime returns file modification time GetModTime() time.Time // GetAccessTime returns file last access time GetAccessTime() time.Time }
FileInfo provides access to file metadata
type FileSystem ¶
type FileSystem interface { // IsDir returns true if a given file path is a directory IsDir(path string) bool // GetFileInfo returns FileInfo for a given file path GetFileInfo(filePath string) (FileInfo, error) // MkDir creates a directory MkDir(path string, mode int) error // OpenFile opens a file and returns its Reader OpenFile(filePath string) (io.ReadCloser, error) // CreateFile creates a new file CreateFile(filePath string, length uint64) (io.WriteCloser, error) // Chmod sets file permissions Chmod(path string, mode int) error // Chtimes sets file access and modification time Chtimes(path string, atime, mtime time.Time) error }
FileSystem is an interface that abstracts file system methods used in SCP command functions
type Flags ¶
type Flags struct { // Source indicates upload mode Source bool // Sink indicates receive mode Sink bool // Verbose sets a logging mode Verbose bool // Target sets targeted files to be transferred Target []string // Recursive indicates recursive file transfer Recursive bool // RemoteAddr is a remote host address RemoteAddr string // LocalAddr is a local host address LocalAddr string // DirectoryMode indicates that a directory is being sent. DirectoryMode bool // PreserveAttrs preserves access and modification times // from the original file PreserveAttrs bool }
Flags describes SCP command line flags