I have the following script:
#!/bin/sh
...
rsync -e 'ssh -i "$SSHKeyPath"'
The error is:
Warning: Identity file $SSHKeyPath not accessible: No such file or directory.
How can I get $SSHKeyGen evaluated before rsync gets called?
UPDATE:
fwiw, this is on OSX.
There are several solutions that I believe are easier:
ssh-agent(1)to unlock the private portion of the key forssh(1)processes as they need it. This is by far the easiest mechanism to use.Use
~/.ssh/configto select a different private key based on hostname:Then there is no need to specify a key on the command line.
Update
Given that you’re trying to separate the key from the individual user, this makes a lot more sense to me now. If you use another variable in
shyou can make your original approach work: