문제

  1. I created an alias for a command that uses a file from one of my directories.

  2. This alias is loaded in .bash_profile in the following format: alias NAME_OF_COMMAND='ssh -i NAME_OF_KEYFILE USER@IP_ADDRESS'

  3. I want to be able to use the alias from anywhere on my system but the KEYFILE (a.k.a. NAME_OF_KEYFILE) is only present in one directory which is not part of my $PATH (it's a subdirectory of dropbox).

  4. I tried to adding that directory to the path with the following command: export PATH=$PATH:/NAME/OF/DIRECTORY

I could see this was nominally successful because when I enter $PATH the new directory shows up at the end of the $PATH variable.

  1. However, when I try to carry out my ssh command I get the error: Warning: Identity file KEYFILE not accessible: No such file or directory.
도움이 되었습니까?

해결책

The path is generally used to search for executables, not data files in general.

Your best bet is probably to change the alias so that the keyfile is a fully qualified path name, something like:

alias myssh='ssh -i $HOME/ssh/mykeyfile.ppk pax@example.com'

With a fully qualified key file, it won't matter where you currently are in the file system (assuming ssh itself is on your path somewhere, of course, but that's a different matter).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top