I set up a dedicated SSH key pair for the purpose of forcing a specific command on a remote server. I added the public key to the remote server authorized_keys file along with a command option specifying the command to be execute when this key is used. The command is a shell script which requires a single command line argument that I'm expecting to get passed in the $SSH_ORIGINAL_COMMAND
environment variable.
When I execute the ssh
command from the client and specify the use of this specific key like this:
ssh -i id_rsa_mykey -o User=abc -o HostName=myhost xxx
The remote script executes as expected and is passed the xxx
in the SSH_ORIGINAL_COMMAND
variable.
If I attempt to pass the remote command an email address however the remote sshd
is interpreting the value as a user@host
and appears to attempt authentication on the part before the @
symbol and the remote command is never executed. /var/log/auth.log
on the remote server has the error:
Invalid user xxx from 192.168.0.1
How can I escape the @
symbol or otherwise not have sshd
evaluate the value as a user@host
and instead pass the value as is to the remote command?
I've tried both attempting to backslash escape the @
symbol as well as using --
before the argument but sshd
does not appear to support this end of arguments convention.
- Client machine is running Ubuntu with
ssh
version OpenSSH_7.2p2. - Server machine is running Debian with
sshd
version OpenSSH_6.7p1
' xxx@yyy '
?ssh remothost ./Echo.sh xxx@yyy
. Where Echo.sh is a script executable in the remote home. Please edit again your post and add the Systems on which you work, and the versions ofssh
andsshd
. BTW-o HostName=myhost
myhost is the remote one. Try to put its IP address (host myhost
). If still not enough try withssh -v ...
to have verbose output of the informations.ssh -i id_rsa_mykey abc@myhost xxx
? Using the options for thehost
anduser
is very weird. Andssh
does not interpret the second@
on the command-line.