LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   ssh to different directory other than home (http://www.linuxquestions.org/questions/linux-software-2/ssh-to-different-directory-other-than-home-502051/)

pridefc 11-15-2006 09:34 PM

ssh to different directory other than home
 
Is there a way to say when a user uses ssh to remotely login, have the user land in a different directory other than his home directory? I don't necessarily want to chroot them. The user should be able to go into other directories where they have access to.
usermod -d /etc/httpd/html/web username works but the shell changes and some commands can't be run after that.

Thanks.

mattrogers 11-15-2006 11:30 PM

I'm not 100% sure, but I don't think there is. logging in with SSH is not much different than logging in from the console while sitting in front of the keyboard and screen.

TheOracle 11-16-2006 04:58 AM

ssh
 
Hi
What about putting the cd command in the .bash_profile of the machine being logged into?

Hth
Graeme

matthewg42 11-16-2006 06:12 AM

If you are an admin with many users for whom you want to do this, you might put something at the end of the /etc/profile, else put it in the user's ~/.bash_profile. Umm, something like:
Code:

if [ "$SSH_CONNECTION" != "" ]; then
    # this is an ssh login, change to the non-home area for this user
    cd /ssh_home/$USER
fi


pridefc 11-16-2006 09:07 PM

Thanks! That totally worked.
Is there a way to do the same when connecting using SSH secure file transfer client?
When using SSH secure file transfer client, the user still lands in home rather than the specifed directory.

Thanks!

matthewg42 11-17-2006 06:12 AM

Do you mean that:
Code:

scp remoteuser@remotehost:filename .
should copy /ssh_home/filename? Hmm, that's more tricky. Don't know.


All times are GMT -5. The time now is 09:37 PM.