scp

package module
v0.0.0-...-3fe2c6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 11 Imported by: 4

README

scp

Go Report Card

A Simple go SCP client library.

Usage

import (
  "github.com/dtylman/scp"
  "golang.org/x/crypto/ssh"
)

Sending Files

Copies /var/log/messages to remote /tmp/lala:

var sc* ssh.Client
// establish ssh connection into sc here...
n,err:=scp.CopyTo(sc, "/var/log/messages", "/tmp/lala")
if err==nil{
  fmt.Printf("Sent %v bytes",n)
}

Receiving Files

Copies remote /var/log/message to local /tmp/lala:

var sc* ssh.Client
// establish ssh connection into sc here...
n,err:=scp.CopyFrom(sc, "/var/log/message", "/tmp/lala")
if err==nil{
  fmt.Printf("Sent %v bytes",n)
}

Documentation

Index

Constants

View Source
const (
	//CopyMessage Copy Message Opcode
	CopyMessage = 'C'
	//ErrorMessage Error OpCode
	ErrorMessage = 0x1
	//WarnMessage Warning Opcode
	WarnMessage = 0x2
)

Variables

This section is empty.

Functions

func CopyFrom

func CopyFrom(sshClient *ssh.Client, remote string, local string) (int64, error)

CopyFrom copy from remote to local

func CopyTo

func CopyTo(sshClient *ssh.Client, local string, remote string) (int64, error)

CopyTo copy from local to remote

Types

type Message

type Message struct {
	Type     byte
	Error    error
	Mode     string
	Size     int64
	FileName string
}

Message is scp control message

func NewMessageFromReader

func NewMessageFromReader(reader io.Reader) (*Message, error)

NewMessageFromReader constructs a new message from a data in reader

func (*Message) ReadError

func (m *Message) ReadError(reader io.Reader) error

ReadError reads an error message

func (*Message) ReadFrom

func (m *Message) ReadFrom(reader io.Reader) (int64, error)

ReadFrom reads message from reader

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL