【发布时间】:2010-12-30 05:13:47
【问题描述】:
我正在编写一个使用 SSH“配置文件”的脚本,~/scripts/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
当我运行脚本时,它失败了:
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:
但这有效:
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!
我的脚本中有错误/陷阱吗?
【问题讨论】:
-
作为实验,将
echo ~添加到脚本的某处。 -
任何实验都是有用的尝试,但你会看到一个只会让你更加困惑〜扩展到主目录但扩展仍然不适用于 ssh。请参阅 Victor 用“eval”回答的原因。
标签: linux bash scripting ubuntu ssh