I'm writing a script for using SSH "profiles", ~/scripts开发者_StackOverflow社区/ssh-profiled.sh
PROFILE=`cat ~/script/ssh-profiles/$1`
echo [ssh $PROFILE]
ssh $PROFILE
~/scripts/ssh-profiles/tummi
-i ~/Dropbox/security/key-nopass/key-nopass.pvt bart@example.com
When I run the script, it fails:
bart@bart-laptop:~$ script/ssh-profiled.sh tummi
[ssh -i ~/Dropbox/security/key-nopass/key-nopass.pvt bart@example.com]
Warning: Identity file ~/Dropbox/security/key-nopass/key-nopass.pvt not accessible: No such file or directory.
bart@example.com's password:
But this works:
bart@bart-laptop:~$ ssh -i ~/Dropbox/security/key-nopass/key-nopass.pvt bart@example.com
Linux tummi 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/Linux
Ubuntu 10.04.1 LTS
Welcome to the Ubuntu Server!
Is there an error/gotcha in my script?
Change 1st line to
eval PROFILE=`cat ~/script/ssh-profiles/$1`
For explanation see here
The ~ in your file needs to be the full home directory path, it's not getting expanded.
My guess is the "~/" is not being interpreted as expected when passed in that way. Try using an explicit full path.
What are the permissions on the .pvt file? If only you have read access, and no one can execute it, then your script might not be able to even see the file. That could be why you are getting the "...not accessible: No such file or directory."
message.
精彩评论