2

ssh remote over gateway

sshpass -p gatewaypwd -t user@gateway sshpass -p targetpwd ssh user2@target this is the origin command,and i am put it to my alias. it run well. but now the target host's password contains single quotes such as

sshpass -p gatewaypwd -t user@gateway sshpass -p target'pwd ssh user2@target the command can not run well. i did try to escape it by \' ,\\\' and other method ,but neither success. how to escape the quotes.

1

2 Answers 2

1
  1. Store your password in text file
  2. Use sshpass -f <filename> ssh user@IP_ADDR

It will take password from file. I have tried this with blank space and it works fine.

1
  • This worked for me, since the password I was using had both single and double quotes in it.
    – Doug Black
    Sep 7, 2022 at 9:10
1

Use double-quotes around the password.

1
  • Much better solution than storing the password in a text file Apr 22, 2022 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.