Quantcast
Channel: How can I automatically change directory on ssh login? - Server Fault
Browsing latest articles
Browse All 13 View Live

Answer by sluge for How can I automatically change directory on ssh login?

I use the following in .ssh/config: RemoteCommand cd ~/mydir;bash RequestTTY force

View Article



Answer by bomben for How can I automatically change directory on ssh login?

Maybe you need to create ~/.bash_profile although you already have a ~/.bashrc.On my debian system the ~/.bashrc was not executed upon login with sshpass.Since I added cd directory to the newly created...

View Article

Answer by kenorb for How can I automatically change directory on ssh login?

Try using RemoteCommand instead, e.g.Host myhost HostName IP User ubuntu IdentityFile ~/.ssh/id_rsa RemoteCommand cd web; $SHELL -ilRemoteCommand: Specifies a command to execute on the remote machine...

View Article

Answer by Aryan for How can I automatically change directory on ssh login?

So I have searched a lot of websites (stackoverflow, this one) but did not find what I wanted. I ended up creating my own shell script. I am pasting it here. Also you can copy it a directory in the...

View Article

Answer by Alex Skrypnyk for How can I automatically change directory on ssh...

More robust solution for the case when you need to ssh and override default .bashrc file. This is useful in cases when remote server environment has multiple docroots and used by multiple users.alias...

View Article


Answer by sobi3ch for How can I automatically change directory on ssh login?

Login to your boxEdit ~/.bash_profileOn the end of the file add cd /path/to/your/destinationSave it & exitLogout from the boxLogin again and then you should land on /path/to/your/destinationNote...

View Article

Answer by Vladislav Lezhnev for How can I automatically change directory on...

This works:ssh server -t "cd /my/remote/directory; bash --login"To create a directory if it doesn't exist: ssh server -t "mkdir -p newfolder; cd ~/newfolder; pwd; bash --login"If you don't add bash to...

View Article

Answer by FlorianP for How can I automatically change directory on ssh login?

You could also try this, with the option -t:ssh server -t "cd /my/remote/directory; bash"

View Article


Answer by Dennis Williamson for How can I automatically change directory on...

In your ~/.ssh/config:LocalCommand echo '/home/%r/some/subdir'> /home/%r/.ssh/ssh_cdAt the end of your ~/.bashrc:if [[ -f $HOME/.ssh/ssh_cd ]]then cd $(<$HOME/.ssh/ssh_cd) # uncomment the line...

View Article


Answer by BMDan for How can I automatically change directory on ssh login?

cd is a shell builtin. LocalCommand is executed as:/bin/sh -c <localcommand>What you're looking to do can't really be accomplished via SSH; you need to modify the shell in some way, e.g. via...

View Article

Answer by James L for How can I automatically change directory on ssh login?

Have you tried it without the quotes around it? The only examples I've seen don't have them so with them it could be trying to execute cd\ web as a command.

View Article

Answer by EEAA for How can I automatically change directory on ssh login?

Have you enabled this directive in your ssh config?PermitLocalCommand yesThe default for that is no, in which case your LocalCommand directive would be ignored.Alternatively, have you tried adding the...

View Article

How can I automatically change directory on ssh login?

I'm trying to get ssh to automatically change to a particular directory when I log in. I tried to get that behaviour working using the following directives in ~/.ssh/config:Host example.netLocalCommand...

View Article

Browsing latest articles
Browse All 13 View Live




Latest Images