I am on macos monterey & have the following in my ~/.ssh/config:
Host foo
HostName cyberark.company.com
User user@user#company.com@target_vm
ssh foo from my terminal has #company.com@target_vm portion of my User value automatically truncated where as ssh user@user#company.com@[email protected] works correctly. Seems like everything after # is treated as comments in .ssh/config file. How do I escape # in this file?
From SSH Config documentation the character
#is a special character interpreted by ssh:You can prevent these behavior from happening by telling explicitly ssh to read litteral characters instead of interpreting them:
\special characters such as#and@(more informations here)'As mentioned in this answer from Martin Prikryl
Here you may want to try the following in your case:
or using backslash: