Skip to content

Commit

Permalink
add error output when using ssh public key
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Mar 26, 2019
1 parent 667b428 commit 199e708
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version := $(shell date "+%Y%m%d%H%M")
GitCommit := $(shell git rev-parse HEAD)
LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)"

run:
go run *.go -conf=example.toml
Expand All @@ -11,6 +14,11 @@ linux:
windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/remote-tail-win.exe *.go

dist:
CGO_ENABLED=0 GOOS=linux go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/remote-tail-linux *.go
CGO_ENABLED=0 GOOS=darwin go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/remote-tail-darwin *.go
CGO_ENABLED=0 GOOS=windows go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/remote-tail.exe *.go

deploy:
scp ./bin/remote-tail-linux root@192.168.1.223:/usr/bin/remote-tail
scp ./bin/remote-tail-linux root@192.168.1.237:/usr/bin/remote-tail
Expand Down
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module github.com/mylxsw/remote-tail

require (
github.com/BurntSushi/toml v0.3.1 // indirect
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c
)
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ var hostStr = flag.String("hosts", "", "-hosts=root@192.168.1.225,root@192.168.1
var configFile = flag.String("conf", "", "-conf=example.toml")
var slient = flag.Bool("slient", false, "-slient=false")

var Version = ""
var GitCommit = ""

func usageAndExit(message string) {

if message != "" {
Expand Down Expand Up @@ -165,8 +168,8 @@ func getWelcomeMessage() string {
| _ < __/ | | | | | (_) | || __/| | (_| | | |
|_| \_\___|_| |_| |_|\___/ \__\___||_|\__,_|_|_|
author: mylxsw
homepage: github.com/mylxsw/remote-tail
version: 0.1.2
Author: mylxsw
Homepage: github.com/mylxsw/remote-tail
Version: ` + Version + "(" + GitCommit + ")" + `
`
}
7 changes: 5 additions & 2 deletions ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ func (this *Client) Connect() error {

if this.Password != "" {
conf.Auth = append(conf.Auth, ssh.Password(this.Password))
}
} else {
privateKey, err := getPrivateKey(this.PrivateKeyPath)
if err != nil {
return err
}

if privateKey, err := getPrivateKey(this.PrivateKeyPath); err == nil {
conf.Auth = append(conf.Auth, privateKey)
}

Expand Down

0 comments on commit 199e708

Please sign in to comment.