forked from toolshed/abra
.gitea
cli
cmd
pkg
app
autocomplete
catalogue
client
config
container
context
dns
envfile
formatter
git
integration
limit
lint
log
recipe
secret
server
service
ssh
ssh.go
test
upstream
web
scripts
tests
vendor
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
27 lines
893 B
Go
27 lines
893 B
Go
package ssh
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Fatal is a error output wrapper which aims to make SSH failures easier to
|
|
// parse through re-wording.
|
|
func Fatal(hostname string, err error) error {
|
|
out := err.Error()
|
|
|
|
if strings.Contains(out, "Host key verification failed.") {
|
|
return fmt.Errorf("SSH host key verification failed for %s", hostname)
|
|
} else if strings.Contains(out, "Could not resolve hostname") {
|
|
return fmt.Errorf("could not resolve hostname for %s", hostname)
|
|
} else if strings.Contains(out, "Connection timed out") {
|
|
return fmt.Errorf("connection timed out for %s", hostname)
|
|
} else if strings.Contains(out, "Permission denied") {
|
|
return fmt.Errorf("ssh auth: permission denied for %s", hostname)
|
|
} else if strings.Contains(out, "Network is unreachable") {
|
|
return fmt.Errorf("unable to connect to %s, please check your SSH config", hostname)
|
|
}
|
|
|
|
return err
|
|
}
|