Hello,
Please note that SHA-1 and SHA-2 are not encryption algorithms. They are cryptographic hash functions (or set cryptographic hash functions in case of SHA-2).
To only enable key SSH exchange algorithms, host key algorithms and MAC algorihms based on SHA-2 and disable those based on SHA-1, use at least Rebex SSH Pack 2016 R3 (although using the latest version is recommended) and call these before connecting:
obj.Settings.SshParameters.SetKeyExchangeAlgorithms(
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group16-sha512",
"diffie-hellman-group15-sha512",
"diffie-hellman-group14-sha256",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"curve25519-sha256@libssh.org");
obj.Settings.SshParameters.SetHostKeyAlgorithms(
"ssh-rsa-sha256@ssh.com",
"rsa-sha2-256",
"rsa-sha2-512",
"x509v3-sign-rsa-sha256@ssh.com",
"ecdsa-sha2-nistp256",
"ecdsa-sha2-nistp384",
"ecdsa-sha2-nistp521",
"ssh-ed25519");
obj.Settings.SshParameters.SetMacAlgorithms(
"hmac-sha2-256-etm@openssh.com",
"hmac-sha2-256",
"hmac-sha2-512-etm@openssh.com",
"hmac-sha2-512");
(Where obj
is an instance of Sftp
, Scp
, Ssh
or FileServer
.)
If you would also like to disable AEAD encryption algorithms such as AES/GCM that are not used with any MAC cipher, only enable the rest:
obj.Settings.SshParameters.SetEncryptionAlgorithms(
"aes256-ctr",
"aes192-ctr",
"aes128-ctr",
"aes256-cbc",
"aes192-cbc",
"aes128-cbc",
"3des-ctr",
"3des-cbc",
"twofish256-ctr",
"twofish192-ctr",
"twofish128-ctr",
"twofish256-cbc",
"twofish192-cbc",
"twofish128-cbc");
(However, we do not believe there is any reason to do this - AEAD ciphers are secure enough.)