Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ssh and changing current login directory
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Voorhees51
Guru
Guru


Joined: 05 Nov 2003
Posts: 358

PostPosted: Wed Sep 21, 2005 7:23 am    Post subject: ssh and changing current login directory Reply with quote

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
View user's profile Send private message
limn
l33t
l33t


Joined: 13 May 2005
Posts: 997

PostPosted: Wed Sep 21, 2005 1:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Voorhees51
Guru
Guru


Joined: 05 Nov 2003
Posts: 358

PostPosted: Wed Sep 21, 2005 2:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
limn
l33t
l33t


Joined: 13 May 2005
Posts: 997

PostPosted: Wed Sep 21, 2005 3:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
nevynxxx
Veteran
Veteran


Joined: 12 Nov 2003
Posts: 1123
Location: Manchester - UK

PostPosted: Wed Sep 21, 2005 3:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum