diff --git a/internal/configure/hosts/hc_get.go b/internal/configure/hosts/hc_get.go index 1f857875e..a8ab33faf 100644 --- a/internal/configure/hosts/hc_get.go +++ b/internal/configure/hosts/hc_get.go @@ -141,6 +141,7 @@ func (hc *HostConfig) GetConnectConfig() *module.ConnectConfig { BecomeUser: hc.GetBecomeUser(), ConnectTimeoutSec: curveadm.GlobalCurveAdmConfig.GetSSHTimeout(), ConnectRetries: curveadm.GlobalCurveAdmConfig.GetSSHRetries(), + Protocol: hc.GetProtocol(), } } diff --git a/internal/configure/hosts/hosts.go b/internal/configure/hosts/hosts.go index c8fa86011..e9ffcfe30 100644 --- a/internal/configure/hosts/hosts.go +++ b/internal/configure/hosts/hosts.go @@ -32,6 +32,7 @@ import ( "github.com/opencurve/curveadm/internal/configure/os" "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/internal/utils" + "github.com/opencurve/curveadm/pkg/module" "github.com/spf13/viper" ) @@ -158,7 +159,7 @@ func (hc *HostConfig) Build() error { F("hosts[%d].private_key_file = %s", hc.sequence, privateKeyFile) } - if hc.GetForwardAgent() == false { + if hc.GetForwardAgent() == false && hc.GetProtocol() == module.SSH_PROTOCOL { if !utils.PathExist(privateKeyFile) { return errno.ERR_PRIVATE_KEY_FILE_NOT_EXIST. F("%s: no such file", privateKeyFile) diff --git a/internal/task/task/checker/ssh.go b/internal/task/task/checker/ssh.go index e3d4f05e0..37ac818c2 100644 --- a/internal/task/task/checker/ssh.go +++ b/internal/task/task/checker/ssh.go @@ -35,6 +35,7 @@ import ( "github.com/opencurve/curveadm/internal/task/step" "github.com/opencurve/curveadm/internal/task/task" "github.com/opencurve/curveadm/internal/utils" + "github.com/opencurve/curveadm/pkg/module" ) const ( @@ -51,7 +52,7 @@ func doNothing() step.LambdaType { func checkHost(hc *hosts.HostConfig) step.LambdaType { return func(ctx *context.Context) error { privateKeyFile := hc.GetPrivateKeyFile() - if hc.GetForwardAgent() == false { + if hc.GetForwardAgent() == false && hc.GetProtocol() == module.SSH_PROTOCOL { if !utils.PathExist(privateKeyFile) { return errno.ERR_PRIVATE_KEY_FILE_NOT_EXIST. F("%s: no such file", privateKeyFile) diff --git a/pkg/module/remote_client.go b/pkg/module/remote_client.go index 81516994c..aad2577eb 100644 --- a/pkg/module/remote_client.go +++ b/pkg/module/remote_client.go @@ -53,6 +53,10 @@ type RemoteClient interface { } func NewRemoteClient(cfg *ConnectConfig) (client RemoteClient, err error) { + if cfg == nil { + return + } + if cfg.Protocol == SSH_PROTOCOL { client, err = NewSSHClient(*cfg.GetSSHConfig()) if err != nil {