
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
本项目是基于golang标准库 ssh 和 sftp 开发,免密实现增量同步
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.96 -p 7994
rsync -torpvg --exclude='temp/' --exclude='Runtime/' /www/wwwroot/ -e 'ssh -p 7994' root@192.168.1.96:/www/wwwroot/
rsync -torpvg --ignore-existing --exclude='.txt' --exclude='temp/' /wwwroot/ -e 'ssh -p 7994' root@192.168.1.96:/wwwroot/
本项目是对标准库进行一个简单的高层封装,使得可以在在 Windows Linux Mac 上非常容易的执行 ssh 命令, 以及文件,文件夹的上传,下载等操作.
go get github.com/pytool/ssh
提供3个方法: Run() Exec() Output()
package main
import (
"fmt"
"github.com/pytool/ssh"
)
func main() {
c, err := ssh.NewClient("localhost", "22", "root", "ubuntu")
if err != nil {
panic(err)
}
defer c.Close()
output, err := c.Output("uptime")
if err != nil {
panic(err)
}
fmt.Printf("Uptime: %s\n", output)
}
package main
import (
"github.com/pytool/ssh"
)
func main() {
client, err := ssh.NewClient( "localhost", "22", "root", "ubuntu")
if err != nil {
panic(err)
}
defer client.Close()
var remotedir = "/root/test/"
// download dir
var local = "/home/ubuntu/go/src/github.com/pytool/ssh/test/download/"
client.Download(remotedir, local)
// upload file
var remotefile = "/root/test/file"
client.Download(remotefile, local)
}
package main
import (
"github.com/pytool/ssh"
)
func main() {
client, err := ssh.NewClient( "localhost", "22", "root", "ubuntu")
if err != nil {
panic(err)
}
defer client.Close()
var remotedir = "/root/test/"
// upload dir
var local = "/home/ubuntu/go/src/github.com/pytool/ssh/test/upload/"
client.Upload(local, remotedir)
// upload file
local = "/home/ubuntu/go/src/github.com/pytool/ssh/test/upload/file"
client.Upload(local, remotedir)
}
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.