Closed capric98 closed 1 year ago
Merging #246 (185707a) into main (e14bbcb) will not change coverage. Report is 1 commits behind head on main. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## main #246 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 55 55
Lines 1686 1690 +4
=========================================
+ Hits 1686 1690 +4
Files Changed | Coverage Δ | |
---|---|---|
conf/config.go | 100.00% <ø> (ø) |
|
flag/flag.go | 100.00% <ø> (ø) |
|
core/vfs.go | 100.00% <100.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
I remove the -ssh_key
flag and add some parameters to -source
and -dest
flags: ssh_user
, ssh_pass
, ssh_key
, ssh_key_pass
, ssh_host_key
.
Use the above parameters to control the sftp authentication, for example:
$ gofs -source="sftp://127.0.0.1:22?remote_path=/gofs_sftp_server&ssh_user=sftp_user&ssh_pass=sftp_pwd&ssh_key=./id_rsa&ssh_key_pass=123456&ssh_host_key=/root/.ssh/known_hosts" -dest="./dest" -sync_once
Please help review the code. @capric98
Great idea, a warning log will be printed when the host key is empty. Please review it again. @capric98
Merged.
Problem: gofs will always throw an error of "invalid ssh key file" when using ssh_key authentication, the problem is from: https://github.com/no-src/gofs/blob/e14bbcb6290010524f68bcd99dc7e74907bb1351/driver/sftp/sftp.go#L109-L120 where
keyFileName
is not"known_hosts"
.Refer to the example from golang.org/x/crypto/ssh, we could use
ssh.InsecureIgnoreHostKey()
as HostKeyCallback function temporarily, because seems likessh.ParseKnownHosts(keyData)
has some other issue, and the host may not be inknown_hosts
file already.Instead, the private key file could be parsed by
ssh.ParsePrivateKey()
to be assh.Signer
and thenssh.PublicKeys()
will convert it tossh.AuthMethod
.