Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible, for each host, to set initial directory where shell would cd into when logged in? (not home)

For example, I have a snippet in ~/.ssh/config

Host mybusiness
Hostname mybusines.com
User plone

And now I can ssh to this host with ssh mybusiness command, but always the first task I need to do is to type in the command cd /srv/www

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

I don't think that's possible, but you could config your shell's init script at the server. If you use bash at the server, you could add this line to the end of ~/.bashrc at the server:

cd /my/initial/dir

Another option is to create a small script on your client for starting SSH-connections, which will run a remote command after login:

#!/bin/sh
# This is the file "/home/myuser/bin/myssh":
ssh $1 "cd /my/initial/dir"

Run it like this:

# myssh mybusiness
share|improve this answer
    
Looks like there is no way around this without creating your own helper scripts :( I'll mark this as correct answer. –  Mikko Ohtamaa Feb 4 '12 at 11:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.