The scp program has an exit status of 0 when the username is invalid. I get the following on both Linux and Cygwin (note the invalid space in the username): >scp file.txt "invalid user@host.com:file.txt" invalid user: invalid user name >echo $? 0
This was fixed in OpenSSH 7.7
Close RESOLVED bugs with the release of openssh-8.0