c# - 如何通过WinSCP检查SFTP session 中使用的加密算法?

标签 c# ssh sftp winscp winscp-net

我正在使用 WinSCPnet,版本=5.19.0 通过 SFTP 进行文件传输。我传输文件的供应商已经弃用了一些密码。我想检查我在代码中使用的 SFTP session 正在使用哪种密码或加密算法。

这是我打开 SFTP 连接的代码:

SessionOptions sessionOptionsSFTP = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = sftpServerIP,
    UserName = sftpUserID,
    Password = sftpPassword,
    PortNumber = sftpPort,
    SshHostKeyFingerprint = sftpHostKey,
    Timeout = new TimeSpan(0, 2, 0)
};

Session sessionSFTP = new Session();

sessionSFTP.Open(sessionOptionsSFTP);
log.Info("SFTP session has been opened");

有没有办法记录或检查正在使用哪种算法?

最佳答案

要检查您的 WinSCP .NET 程序集版本支持哪些算法,请在程序集包中查找 winscp.exe 二进制文件(或单独查找 download WinSCP 5.19 二进制文件)。

并使用 /info command-line parameter 运行它。您将得到:

SSH encryption ciphers:
aes256-ctr
aes256-cbc
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e092898a8e8481858ccd838283a08c999381948f92ce8c8995ce9385" rel="noreferrer noopener nofollow">[email protected]</a>
aes192-ctr
aes192-cbc
aes128-ctr
aes128-cbc
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1b2b9b0b2b9b0e3e1fca1bebda8e0e2e1e491bea1b4bfa2a2b9ffb2bebc" rel="noreferrer noopener nofollow">[email protected]</a>
blowfish-ctr
blowfish-cbc
3des-ctr
3des-cbc
arcfour256
arcfour128
des-cbc
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fb9f9e88d6989998bb888893d5989496" rel="noreferrer noopener nofollow">[email protected]</a>
...

要检查 session 实际使用的算法,请检查 session 日志文件。通过设置 Session.SessionLogPath 启用它.

. 2023-10-31 12:30:38.501 Have a known host key of type ecdsa-sha2-nistp521
. 2023-10-31 12:30:38.503 Doing ECDH key exchange with curve Curve25519, using hash SHA-256
. 2023-10-31 12:30:38.762 Server also has ssh-ed25519/ecdsa-sha2-nistp256/ecdsa-sha2-nistp384/ssh-dss/rsa-sha2-512/rsa-sha2-256/ssh-rsa host keys, but we don't know any of them
. 2023-10-31 12:30:38.763 Host key fingerprint is:
. 2023-10-31 12:30:38.763 ecdsa-sha2-nistp521 521 SHA256:p3ZteKYBFsSyFh18yOaczZEqoXnn135qqH1VqdIzQ8k
< 2023-10-31 12:30:38.764 Script: Authenticating...
. 2023-10-31 12:30:38.765 Host key matches configured key fingerprint
. 2023-10-31 12:30:38.766 Initialised AES-256 SDCTR (AES-NI accelerated) [aes256-ctr] outbound encryption
. 2023-10-31 12:30:38.766 Initialised HMAC-SHA-256 outbound MAC algorithm
. 2023-10-31 12:30:38.766 Initialised AES-256 SDCTR (AES-NI accelerated) [aes256-ctr] inbound encryption
. 2023-10-31 12:30:38.766 Initialised HMAC-SHA-256 inbound MAC algorithm

尽管我强烈建议您不要使用旧版本的 WinSCP。请改用最新版本。

关于c# - 如何通过WinSCP检查SFTP session 中使用的加密算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77395191/

相关文章:

python - "ssh"Paramiko 中的等效代理命令

c# - 如何在 Task.factory.fromAsync 中使用 void 方法

c# - 与 ViewModel 绑定(bind)的 MVVM 动态菜单 UI

python - 在 Python 中使用 Paramiko ssh 到 ftp 服务器

linux - 使用 Bash 脚本自动插入密码

vim - 远程Vim找不到文件

c# - "Merging"类型,不使用反射或重复代码?

c# - 尝试从文本框中获取 int 时出错

git - 是否可以使用 SSH 协议(protocol)在 gitlab.com 上镜像私有(private)存储库?

eclipse - 如何使用 "Remote System Explorer End-User Runtime"Eclipse 插件和 .pem 私钥连接到 SFTP 服务器?