我正在编写一个使用SSH“配置文件”的脚本,〜/ scripts / ssh-profiled.sh
PROFILE=`cat ~/script/ssh-profiles/$1`
echo [ssh $PROFILE]
ssh $PROFILE
〜/脚本/ SSH型材/ tummi
-i ~/Dropbox/security/key-nopass/key-nopass.pvt [email protected]
当我运行脚本时,它失败了:
[email protected]:~$script/ssh-profiled.sh tummi
[ssh -i ~/Dropbox/security/key-nopass/key-nopass.pvt [email protected]]
Warning: Identity file ~/Dropbox/security/key-nopass/key-nopass.pvt not accessible: No such file or directory.
[email protected]'s password:
但这有效:
[email protected]:~$ssh -i ~/Dropbox/security/key-nopass/key-nopass.pvt [email protected]
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!
我的脚本中是否有错误/陷阱?
将第1行更改为
eval PROFILE=`cat ~/script/ssh-profiles/$1`
有关解释,请参阅here