[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: login into a particular directory using ssh



On Sun, 05 Dec 2004 18:48:19 -0500, David Mandelberg
<mandelbergd@eth0.is-a-geek.org> wrote:
> Miquel van Smoorenburg wrote:
> >       ssh -t joe@shell.example.net 'cd / && exec /bin/bash'
> 
> That works, but because this is a login shell, and the remote machine
> may differentiate between login and non-login shells, this is better:
> 
> ssh -t joe@shell.example.net 'cd / && exec /bin/bash --login -i'
> 
> Also don't forget the exec because otherwise you'd be running an extra
> shell or the single quotes before cd and after -i.
> 

This does work perfectly. I am wondering if there is a clever trick to
do the following.

In the above examples we are specifying the destination directory. But
can this directory be obtained from the original machine?

For example, can I do something like

bash$export DYNAMIC=$(basename $PWD)
bash$ssh -t joe@shell.example.net 'cd $DYNAMIC && exec /bin/bash --login -i'

which dynamically determines the current directory on the ssh client
and puts me into that directory on the shell.example.net? Needless to
say, I tried the above example and it does not work.

thanks for all the replies
raju

-- 
Kamaraju S Kusumanchi
Cornell University
http://people.cornell.edu/pages/kk288/
http://groups.yahoo.com/group/flumech/



Reply to: