LoginSignup
6
6

More than 5 years have passed since last update.

【bash】ダブルコーテーション内で特殊文字が文字列として扱われる

Last updated at Posted at 2015-07-01

わかれば当たり前だけどはまったのでメモ。
ダブルコーテーション内では特殊文字(チルダなど)は文字列扱われる。

sshの鍵認証でrsyncしようとして、sshの鍵のパスをチルダで書いてしまったため、鍵がないというエラーが出た。
ダブルコーテーションの件に気付かず、ずっとrsyncの仕様を調べてはまった。

間違った例
rsync -r  -e "ssh -i ~/.ssh/keyfile" /path/to/dir  username@example.com:/path/to/foo/

=>Warning: Identity file ~/.ssh/keyfile not accessible: No such file or directory.
正しい例
#ダブルコーテーションなのでフルパスで書きましょう。
rsync -r  -e "ssh -i /home/foo/.ssh/keyfile" /path/to/dir  username@example.com:/path/to/foo/

参考:rsync + sshで鍵ファイル認証でリモートサーバに転送する方法

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6