Rito
Rito

Reputation: 3290

When trying to use sshpass command with alias, getting Permission denied response

When I am trying to make a normal sshpass command in my terminal it is working correctly. This is the command I am using:

sshpass -p 'Rito$pass@20' ssh '[email protected]'

When I am trying to use the same command by creating an alias, it is responding Permission denied, please try again.

I have created my alias in .profile file. This is how my alias looks:

alias myalias="sshpass -p 'Rito$pass@20' ssh [email protected]"

Can anyone please explain why I am getting Permission denied error when I am trying to use the alias, and how to resolve it?

=================================================================

Update:

Based on @pynexj comment I ran the command set -x; myalias; set +x and found that the characters post $ are not getting considered in the password. My password was Rito$pass@20 but it was considering only Rito@20, that is all the characters after including the $ is ignored till the @ character.

Upvotes: 1

Views: 1352

Answers (2)

syed adeeb
syed adeeb

Reputation: 139

if your password contains special characters such as $... eg abcd@1234$$ then use \ with the special character....add this \ before each $$....it worked for me.... in your case add \ before $ or \ after o in 'Rito$pass@20'

Upvotes: 1

pynexj
pynexj

Reputation: 20688

According to the comment, there's a $ char in the password. So to fix you need to escape the $ char.

For example if the password is pa$$word:

alias myalias="sshpass -p 'pa\$\$word' ssh [email protected]"

Upvotes: 0

Related Questions