Re: Same directory

Sensei wrote:
On 2007-01-15 14:50:10 +0100, Xavier Décoret <Xavier.Decoret@xxxxxxx> said:


I cannot find the following information: how do I ssh on a remote login so that on the remote machine, I end up in a given directory (e.g. the current directory if I ssh on a machine that mounts the same home dir).

By /default/ using ssh you *log in*, so you create a session for a user on the remote machine.

If I ssh with ``sensei'' on from my client, and on my client I am logged as ``sensei'', the two homonymous users have nothing in common. You always end up in the user home directory.

You are right. Since you can use ssh to run a command remotely, I was hopping that you could run a command, like cd, and *then* stay logged to type interactive command.

Finally, I came up with a kind-of-solution that I post here for those interested:

In your .login, put:
if ($?SSH_PWD) then

In your .tcshrc (adapt if you use bash)
alias ssh 'env SSH_PWD=$PWD ssh'

In .ssh/config, put:

In the /etc/ssh/sshd_config of the client, put:
AcceptEnv SSH_PWD
(and be sure to restart the sshd service [eg: service sshd restart]

This last point makes the solution really a hack: you need to be root on the client. In my case, where I want to log within a parc of machines in my building, that mount the same homedirs, it was quite easy to propagate this setup on the whole parc. This way, when I am working on my machine in a directory and want to log onto another machine (typically the one with the dongle that let me run some special app), I stay in the same dir.