diff --git a/lib/client/client.go b/lib/client/client.go index 6d6d08f09f559..10765a50b9ef3 100644 --- a/lib/client/client.go +++ b/lib/client/client.go @@ -722,7 +722,15 @@ func (c *NodeClient) TransferFiles(ctx context.Context, cfg *sftp.Config) error ) defer span.End() - return trace.Wrap(cfg.TransferFiles(ctx, c.Client.Client)) + if err := cfg.TransferFiles(ctx, c.Client.Client); err != nil { + if trace.IsBadParameter(err) && strings.Contains(err.Error(), "expanding remote ~user paths is not supported") { + return trace.Wrap(&NonRetryableError{Err: err}) + } + + return trace.Wrap(err) + } + + return nil } type netDialer interface { diff --git a/lib/sshutils/sftp/sftp.go b/lib/sshutils/sftp/sftp.go index b16eb656a3557..0d1b6a23fe8c5 100644 --- a/lib/sshutils/sftp/sftp.go +++ b/lib/sshutils/sftp/sftp.go @@ -329,7 +329,7 @@ func (c *Config) expandPaths(srcIsRemote, dstIsRemote bool) (err error) { for i, srcPath := range c.srcPaths { c.srcPaths[i], err = expandPath(srcPath) if err != nil { - return trace.Wrap(err, "error expanding %q", srcPath) + return trace.Wrap(err) } } } @@ -337,7 +337,7 @@ func (c *Config) expandPaths(srcIsRemote, dstIsRemote bool) (err error) { if dstIsRemote { c.dstPath, err = expandPath(c.dstPath) if err != nil { - return trace.Wrap(err, "error expanding %q", c.dstPath) + return trace.Wrap(err) } } @@ -358,7 +358,7 @@ func expandPath(pathStr string) (string, error) { return ".", nil } if pfxLen == 1 && len(pathStr) > 1 { - return "", trace.BadParameter("expanding remote ~user paths is not supported, specify an absolute path instead") + return "", trace.BadParameter("expanding remote ~user paths is not supported, specify an absolute path instead of %q", pathStr) } // if an SFTP path is not absolute, it is assumed to start at the user's