1

I have a shell script authenticate.sh that looks like

#!/bin/bash
sshpass -p '$1' ssh $2@localhost

I call it using

bash authenticate.sh password username

But I get "Permission denied, please try again" when I run it. If I instead run

#!/bin/bash
sshpass -p 'password' ssh user@localhost

it works...

Any help?

1 Answers1

1

The single apostrophes must have just thrown the script off, see note below.

This works as intended:

#!/bin/bash
sshpass -p "$1" ssh "$2"@localhost

This is because single apostrophes do not allow any variables expanded inside.