Setting a Cipher in .ssh/config (Client-Side)
To specify a cipher for an SSH connection in the client configuration file(~/.ssh/config), use the Ciphers directive.
Example: Setting a Preferred Cipher for a Specific Host:
Host remote-server
Ciphers aes256-gcm@openssh.com,aes256-ctr
To enforce a specific ciphers for all SSH connections, use:
Host *
Ciphers aes256-gcm@openssh.com,aes256-ctr
Verifying the Cipher in Use
To check which cipher is being used for an SSH connection, run:
ssh -vv user@remote-server | grep "cipher"
Example Output:
debug1: kex: algorithm: curve25519-sha256
debug1: cipher: aes256-gcm@openssh.com
aes256-gcm@openssh.com or aes256-ctr.
Ciphers aes256-ctr,
it will reject any cipher outside that set, regardless of the client’s preference.