ssh startup script working?


Forum: Networking
Topic: ssh startup script working?
started by: spiroc

Posted by spiroc on Sep. 17 2008,04:33
Hi,
I want to add a login script for my ssh sessions.  I have tried to create /etc/ssh/sshrc and also ~/.ssh/rc but neither of them are getting called.  I have tried direct commands as the contents of the script eg:

alias l="ls -al"

as well as trying a "source" command which I read as a suggestion somewhere eg

source startupcommands

(where the file startupcommands is the one that contains my real commands) but no luck so far.

Can anyone tell me if they have seen either /etc/ssh/sshrc or ~/.ssh/rc being called, and if so, what I should check on my box.  (I have tried lots of different file permissions but still nothing).

thanks

Spiroc

Posted by ^thehatsrule^ on Sep. 18 2008,06:23
sshrc might depend on the version of sshd.  I think DSL includes some version of openssh.

You could always just use your shell's startup scripts, i.e. bashrc.  If you need to only use those aliases for ssh sessions, you could wrap the code in something like
Code Sample
if [ -n "$SSH_CLIENT" ]; then
 # insert code here
fi

Posted by spiroc on Sep. 22 2008,00:53
Thanks for the reply.  Unfortunately .bashrc is where I first tried putting it.  It's only called when opening up "an interactive shell which is not a login shell" which I never really thought about before.  It means that my .bashrc entries are working when I open up a term in DSL but not when I ssh into the box.  You did give my an idea though.  I setup my putty session so the that Remote Command (its in the SSH section of the putty config) is simply: bash.  And now .bashrc is being called and its working. thanks :D
Posted by ^thehatsrule^ on Sep. 22 2008,01:00
Ah, ssh session would imply login shells.  You could add it in /etc/profile or .bash_profile then (maybe sourcing bashrc from it instead is better) but it seems you've found a way to do it.
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.