I'm using the following.
Have a shell command, called myssh
, with content:
PROFILE="$1";shift;
DEF="Basic" #the default profile name
echo "tell app \"Terminal\" to set current settings of first window to settings set \"${PROFILE}\""|osascript
ssh $@
echo "tell app \"Terminal\" to set current settings of first window to settings set \"${DEF}\""|osascript
and use bash aliases for the connect, like:
alias ssweb='myssh Homebrew user@web.example.com'
alias ssmail='myssh Ocean me@mail.example.com'
When I want to ssh into the web server, I simply write ssweb
in the Terminal and I got the "Homebrew" profile. When the ssh session ends, the AppleScript sets back to the "Basic".
The aliases should go into your $HOME/.profile or similar bash-startup file.
The "Homebrew", "Ocean" etc. are the setting profiles from the Terminal.app preferences. You can also set up different fonts, encodings, etc.
Of course, you can use it directly (without aliases) like:
myssh Pro user@another.machine.example.com
^ ^
| ssh command arguments
terminal profile name
In Mountain Lion the sshd
configuration (/etc/sshd_config
) was changed and sshd
no longer looks at ~/.ssh/authorized_keys2
for valid keys.
/etc/sshd_config
on Lion (line 46):
#AuthorizedKeysFile .ssh/authorized_keys
/etc/sshd_config
on Mountain Lion (line 48):
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
If you don’t wish to edit the /etc/sshd_config
on the target machine you can either rename ~/.ssh/authorized_keys2
to ~/.ssh/authorized_keys
or symlink it.
Symlink ~/.ssh/authorized_keys
to ~/.ssh/authorized_keys2
ln -s ~/.ssh/authorized_keys ~/.ssh/authorized_keys2
Rename ~/.ssh/authorized_keys2
mv ~/.ssh/authorized_keys2 ~/.ssh/authorized_keys
Best Answer
It doesn't work because the
cd
is executed on your local machine when thessh
does terminate.Here is the way to do it: