I use PuTTY to connect to a remote server. I want my SSH session to start on a folder that I specify on the server, so I won't have to do cd /my/path/ every time I log in. Possible?

link|improve this question

72% accept rate
feedback

2 Answers

up vote 1 down vote accepted

If you only want the behavior when you log in through PuTTY, you can use "remote command" in the PuTTY configuration dialog (under Connection/SSH). You would type

cd /my/path ; /bin/myshell

into the "remote command" field. If you have more complicated stuff to set up, you would type in the name of a script /home/yourname/yourscript for "remote command" which contains something like

cd /my/path
all-other-stuff-I-need-to-do
/bin/myshell

You need to start the shell manually in your script, otherwise the SSH session will terminate right after your script finishes.

"remote command" has the advantage that you can create different saves sessions in PuTTY where different scripts are called (if you need that).

Of course, if you always want to have the same directory (independent of PuTTY) when you log into your account, you can add the cd command to ~/.profile or ~/.bash_profile as explained by grawity.

link|improve this answer
feedback

You can add the command to ~/.profile (or ~/.bash_profile) to be automatically ran on every login.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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