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

Re: login into a particular directory using ssh

ssh user@hostname "sh -c 'cd dirname; exec somecommand'"

somecommand is the command you want to run after cd'ing. E.g. if you
want to run bash in / as joe at shell.example.net:

ssh joe@shell.example.net "sh -c 'cd /; exec bash'"

Kamaraju Kusumanchi wrote:
> I am trying to ssh from A to B. I want to login into a particular
> directory on B instead of $HOME. How can I do this?
> I tried 
> ssh user@hostname cd dirname
> but that is not working. Any other ideas?
> thanks
> raju

Version: 3.1
GAT/CM$/CS>$/CC/IT$/M/S/O/U dpu s+:++ !a C++$>C+++$
UB+++>++++$L++++$*-- P+>++$ L+++(++++)$ E-(---) W+++>$ N(+) o? K-
w--(---) O? M V? PS++@ PE-@ Y+@ PGP++(+++)>$ t? 5? X? R tv--(-)
b++(+++)@ DI? D? G e->++++ h* r? z*

David Mandelberg

Attachment: signature.asc
Description: OpenPGP digital signature

Reply to: