deploy icon indicating copy to clipboard operation
deploy copied to clipboard

Tilde expansion fails for ssh key value

Open mehulved opened this issue 10 years ago • 6 comments

I tried using tilde for my ssh key path. But that fails to find the key. I ensured that the path was correct. But, when I replaced the tilde with user homedir path, it worked fine. Is the tilde expansion disabled or does it expand to root path? I did execute the script as own user. And there's the ssh key in that user's path.

mehulved avatar Sep 23 '13 15:09 mehulved

What doesn't work

$ deploy development setup
Warning: Identity file ~/.ssh/id_dsa.pub not accessible: No such file or directory.
$ cat deploy.conf 
[development]
key ~/.ssh/id_dsa.pub
user mehul

What works

$ cat deploy.conf 
[development]
key /home/mehul/.ssh/id_dsa.pub
user mehul
$ deploy development setup
Enter passphrase for key '/home/mehul/.ssh/id_dsa.pub': 

mehulved avatar Sep 23 '13 18:09 mehulved

I see this issue over and over again, when script ssh commands. I'd love to hear an explanation why. Simple avoidance is to replace '~' with "$HOME" when parsing configuration.

jmervine avatar Oct 25 '13 00:10 jmervine

This is how bash works. As soon as a tilde has been quoted, i.e., '~', it will not be expanded. Usually one bypasses this by using $HOME instead.

One can expand tilde by using eval, but usually one want to avoid this. See http://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html for more information.

hovsater avatar Nov 03 '13 09:11 hovsater

Is there a solution for that? Both ~ and $HOME are not working

micky2be avatar Jan 13 '16 07:01 micky2be

Nothing?

micky2be avatar Mar 22 '16 05:03 micky2be

@micky2be I created a pull request of pm2-deploy to solve the same problem, if you're interested. https://github.com/Unitech/pm2-deploy/pull/81

2hu12 avatar Apr 06 '16 05:04 2hu12