简体   繁体   中英

how to escape the single quotes when use sshpass

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. 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.

在密码周围使用双引号。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM