ssh by default only goes to the home directory ~. I'm wondering if there is a way to supply a directory (that is /home/name/some_dir in this case) to it, so that it will go to the directory directly.
$pwd /home/name/some_dir $ssh localhost # I want to change the directory to /home/name/some_dir after sshed to localhost $pwd /home/name
On Oct 10, 11:03 am, Peng Yu <pengyu...@gmail.com> wrote:
> ssh by default only goes to the home directory ~. I'm wondering if > there is a way to supply a directory (that is /home/name/some_dir in > this case) to it, so that it will go to the directory directly.
> $pwd > /home/name/some_dir > $ssh localhost # I want to change the directory to /home/name/some_dir > after sshed to localhost > $pwd > /home/name
I don't think there's anything built in, but you could do something like this:
# ssh targethost '(cd /targetdir; /bin/bash)'
That should get you a working shell in the target directory, and terminate your connection when you leave that shell.
Nico Kadel-Garcia <nka...@gmail.com> writes: > Peng Yu <pengyu...@gmail.com> writes: > > ssh by default only goes to the home directory ~. I'm wondering if > > there is a way to supply a directory (that is /home/name/some_dir in > > this case) to it, so that it will go to the directory directly. > I don't think there's anything built in, but you could do something > like this:
> # ssh targethost '(cd /targetdir; /bin/bash)'
> That should get you a working shell in the target directory, and > terminate your connection when you leave that shell.
You need to add -t, otherwise your shell will think it's reading a script from /dev/stdin rather than running an interactive session. You won't get a prompt, command-line editing etc., and you won't be able to run any screen-oriented programs (such as top).
> Nico Kadel-Garcia <nka...@gmail.com> writes: > > Peng Yu <pengyu...@gmail.com> writes: > > > ssh by default only goes to the home directory ~. I'm wondering if > > > there is a way to supply a directory (that is /home/name/some_dir in > > > this case) to it, so that it will go to the directory directly. > > I don't think there's anything built in, but you could do something > > like this:
> > # ssh targethost '(cd /targetdir; /bin/bash)'
> > That should get you a working shell in the target directory, and > > terminate your connection when you leave that shell.
> You need to add -t, otherwise your shell will think it's reading a > script from /dev/stdin rather than running an interactive session. You > won't get a prompt, command-line editing etc., and you won't be able to > run any screen-oriented programs (such as top).
Peng Yu <pengyu...@gmail.com> writes: >On Oct 10, 12:21=A0pm, Dag-Erling Sm=F8rgrav <d...@des.no> wrote: >> Nico Kadel-Garcia <nka...@gmail.com> writes: >> > Peng Yu <pengyu...@gmail.com> writes: >> > > ssh by default only goes to the home directory ~. I'm wondering if >> > > there is a way to supply a directory (that is /home/name/some_dir in >> > > this case) to it, so that it will go to the directory directly. >> > I don't think there's anything built in, but you could do something >> > like this:
>> > That should get you a working shell in the target directory, and >> > terminate your connection when you leave that shell.
>> You need to add -t, otherwise your shell will think it's reading a >> script from /dev/stdin rather than running an interactive session. =A0You >> won't get a prompt, command-line editing etc., and you won't be able to >> run any screen-oriented programs (such as top).
>> DES >> -- >> Dag-Erling Sm=F8rgrav - d...@des.no >I tried the following command. >ssh targethost '(cd /targetdir; /bin/bash -t)' >It does not give a prompt. When I type 'top', it prints 'TERM >environment variable not set.' then return to the shell in my local >machine. >Would you please help test if you also see the same thing?
Uh, -t is the argument to ssh, not to bash. ssh -t target 'cd /targetdir; /bin/bash ' for example.