Unable to assign the SSH version number to a variable in bash. Running the below code, the output from "uname -a" is assigned to the variable "os", however the output from "ssh -v" appears in the terminal window but isn't assigned to the variable "ssh_v".
Confirmed this is happening on various versions of Solaris and Ubuntu and I have no idea why.
CODE:
#!/usr/bin/env bash
ssh_v=$(ssh -V)
printf "ssh_version = $ssh_v\n"
os=$(uname -a)
printf "OS_version = $os\n"
OUTPUT:
root@myserver:/usr/build/run# ./test.sh
Sun_SSH_2.4, SSH protocols 1.5/2.0, OpenSSL 0x100020bf
ssh_version =
OS_version = SunOS myserver 5.11 11.3 sun4v sparc sun4v