Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: ssh startup script working?< Next Oldest | Next Newest >
spiroc Offline





Group: Members
Posts: 5
Joined: Feb. 2005
Posted: Sep. 17 2008,04:33 QUOTE

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
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 18 2008,06:23 QUOTE

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
Back to top
Profile PM 
spiroc Offline





Group: Members
Posts: 5
Joined: Feb. 2005
Posted: Sep. 22 2008,00:53 QUOTE

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
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 22 2008,01:00 QUOTE

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.
Back to top
Profile PM 
3 replies since Sep. 17 2008,04:33 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: ssh startup script working?

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code