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.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer

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

share|improve this answer

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.