ich ein Skript zu schreiben für die Verwendung von SSH "Profile", ~/scripts/ssh-profiled.shBefehl nicht in Skript arbeiten, sondern arbeitet in der Schale
PROFILE=`cat ~/script/ssh-profiles/$1`
echo [ssh $PROFILE]
ssh $PROFILE
~/scripts/ssh-Profile/Tummi
-i ~/Dropbox/security/key-nopass/key-nopass.pvt [email protected]
Als ich das Skript ausführen, es scheitert:
[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:
Aber das funktioniert:
[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!
Gibt es einen Fehler/Gotcha in meinem Skript?
Als ein Experiment, fügen Sie 'echo ~' zum Skript irgendwo hinzu. – Pointy
Jedes Experiment ist nützlich, um es zu versuchen, aber das wird Sie nur verwirrender machen, da Sie sehen, ~ expandiert in das Home-Verzeichnis, aber die Erweiterung funktioniert immer noch nicht für ssh. Siehe Victors Antwort mit "eval" für warum. – camh