Score:1

Connecting via ssh to remote and go to same directory as used on client

in flag

I have a very specific question. Is it somehow possible to connect from my client via ssh to a remote machine and stay on the same directory I used on the client?

For example if I am in the folder /path/to/folder/ I want to login to the remote machine and go directly to the same folder. If I logout from the remote, go to another folder, let's say /path/to/folder/test/, and log in again via ssh I want to connect to my remote machine and go to this other folder.

Currently I have in my config file the following which works fine but only for ONE specific folder:

Host test
    Hostname test-server
    User user
    IdentityFile ~/.ssh/id_rsa
    RemoteCommand cd /path/to/folder && exec bash --login
    RequestTTY yes

I tried to change cd /path/to/folder/ to cd ${PWD} but that only directs to my home folder and not the path I was working in on the client. Is there any chance to implement the behavior I want? I am grateful for any kind of help. If you need any additional information just let me know.

Many thanks, Daniel

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.