View previous topic :: View next topic |
Author |
Message |
Voorhees51 Guru


Joined: 05 Nov 2003 Posts: 358
|
Posted: Wed Sep 21, 2005 7:23 am Post subject: ssh and changing current login directory |
|
|
Is there a way to change the directory that you go to when you ssh into a box.
if I want to go to /home/user_name/Work is there a way to do this from ssh
other than to just ssh into the box and have to cd to that directory |
|
Back to top |
|
 |
limn l33t

Joined: 13 May 2005 Posts: 997
|
Posted: Wed Sep 21, 2005 1:44 pm Post subject: |
|
|
Here are a couple of ways to do this.
OpenSSH sets SSH_TTY and a couple of other variables when you log in.
You could add something like to your ~/.bash_profile:
Code: | if [[ $SSH_TTY ]]; then
cd /home/user_name/Work
fi |
or
Code: | [ -n "$SSH_TTY" ] && cd /home/user_name/Work |
The two other ssh packages, ossh and ssh, likely set SSH_TTY or something similar.
If you use ~/.ssh/authorized_keys and OpenSSH, you could add
Code: | command="cd /home/user_name/Work;$SHELL" |
at the beginning of that file.
HTH |
|
Back to top |
|
 |
Voorhees51 Guru


Joined: 05 Nov 2003 Posts: 358
|
Posted: Wed Sep 21, 2005 2:33 pm Post subject: |
|
|
ok I'll look into that
is there a way to do it when you're sshing into the system, because I don't always want to go to the same directory when I log in |
|
Back to top |
|
 |
limn l33t

Joined: 13 May 2005 Posts: 997
|
Posted: Wed Sep 21, 2005 3:01 pm Post subject: |
|
|
Voorhees51 wrote: | is there a way to do it when you're sshing into the system, because I don't always want to go to the same directory when I log in |
Not sure I understand you. If you ssh to the system and allocate a tty, the above will put you in /home/user_name/Work. If you log in with another method, it won't. On what would going to a different directory depend? |
|
Back to top |
|
 |
nevynxxx Veteran

Joined: 12 Nov 2003 Posts: 1123 Location: Manchester - UK
|
Posted: Wed Sep 21, 2005 3:19 pm Post subject: |
|
|
If you use putty to ssh in you can have it run a command as soon as it logs in.
Just set a couple of different profiles up with directories you want to move into. _________________ My Public Key
Wanted: Instructor in the art of Bowyery |
|
Back to top |
|
 |
|