mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 07:41:10 +08:00
修改ssh部署
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
/data/
|
||||||
|
/logs/
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type SSHConfig struct {
|
|||||||
PrivateKey string `json:"key"` // 可选
|
PrivateKey string `json:"key"` // 可选
|
||||||
Host string
|
Host string
|
||||||
Port any
|
Port any
|
||||||
|
Mode string `json:"mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoteFile struct {
|
type RemoteFile struct {
|
||||||
@@ -59,7 +60,14 @@ func writeMultipleFilesViaSSH(config SSHConfig, files []RemoteFile, preCmd, post
|
|||||||
default:
|
default:
|
||||||
port = "22"
|
port = "22"
|
||||||
}
|
}
|
||||||
|
IPtype := public.CheckIPType(config.Host)
|
||||||
|
if IPtype == "IPv6" {
|
||||||
|
config.Host = "[" + config.Host + "]"
|
||||||
|
}
|
||||||
addr := fmt.Sprintf("%s:%s", config.Host, port)
|
addr := fmt.Sprintf("%s:%s", config.Host, port)
|
||||||
|
if config.Mode == "" || config.Mode == "password" {
|
||||||
|
config.PrivateKey = ""
|
||||||
|
}
|
||||||
|
|
||||||
authMethods, err := buildAuthMethods(config.Password, config.PrivateKey)
|
authMethods, err := buildAuthMethods(config.Password, config.PrivateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -220,3 +220,14 @@ func ExecCommand(command string) (string, string, error) {
|
|||||||
|
|
||||||
return stdout.String(), stderr.String(), err
|
return stdout.String(), stderr.String(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CheckIPType(address string) string {
|
||||||
|
ip := net.ParseIP(address)
|
||||||
|
if ip == nil {
|
||||||
|
return "Invalid IP"
|
||||||
|
}
|
||||||
|
if ip.To4() != nil {
|
||||||
|
return "IPv4"
|
||||||
|
}
|
||||||
|
return "IPv6"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user