0
home_path='~'
ssh-keyscan -t rsa "$EI_CI_HOST" >> "$home_path/.ssh/known_hosts"

Results in:

bash: ~/.ssh/known_hosts: No such file or directory

When I do the following it works though:

ssh-keyscan -t rsa "$EI_CI_HOST" >> ~/.ssh/known_hosts
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
basickarl
  • 37,187
  • 64
  • 214
  • 335
  • 2
    I'm pretty sure that's because `~` is not expanded and is treated as a literal `~`. Use the variable `$HOME` instead. – Aserre Aug 16 '18 at 13:52
  • 1
    It'll be expanded if you don't put it in quotes. `home_path=~` would work... though using `$HOME` is indeed the better practice. – Charles Duffy Aug 16 '18 at 13:53
  • (well -- `$HOME` wouldn't be expanded either in single quotes, but if you made it double quotes `$HOME` would work, whereas `~` still wouldn't). – Charles Duffy Aug 20 '18 at 00:33

0 Answers0