scp

package module
v0.0.0-...-73ecc5a Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

README

go-scp

Simple SCP Package with Recursive copy support

SCP Protocol Information

How SCP Protocol Works

Example

package main

import (
	"log"
	"os"

	"github.com/aedavelli/go-scp"
)

func main() {
	if len(os.Args) < 2 {
		log.Fatal("Usage: ", os.Args[0], " <path1> <path2> ...")
	}
	c, err := scp.NewDumbClient("username", "password", "server.com:22")

	if err != nil {
		log.Fatal(err)
	}

	c.Quiet = true
	err = c.Send("/tmp", os.Args[1:]...)
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Overview

This package provides simple SCP client for copying data recursively to remote server. It's built on top of x/crypto/ssh

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	SshClient    *ssh.Client
	PreseveTimes bool
	Quiet        bool
}

func NewClient

func NewClient(c *ssh.Client, pt bool) *Client

Creates a new SCP client form ssh.Client and preserve time stamps

func NewDumbClient

func NewDumbClient(username, password, server string) (*Client, error)

Creates a new SCP client. Use this only with trusted servers, as the host key verification is bypassed. It enables preserve time stamps

func (*Client) Send

func (c *Client) Send(dst string, paths ...string) error

Send the files dst directory on remote side. The paths can be regular files or directories.

Example
if len(os.Args) < 2 {
	log.Fatal("Usage: ", os.Args[0], " <path1> <path2> ...")
}
c, err := scp.NewDumbClient("username", "password", "server.com:22")

if err != nil {
	log.Fatal(err)
}

c.Quiet = true
err = c.Send("/tmp", os.Args[1:]...)
if err != nil {
	log.Fatal(err)
}
Output:

Jump to

Keyboard shortcuts

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