Re: Same directory



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

Hi,

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 ssh.blah.com from my client client.blah.com, 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
cd $SSH_PWD
endif

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

In .ssh/config, put:
SendEnv SSH_PWD

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.

X.
.



Relevant Pages

  • Re: OT: Hard disk mirror with Paragon on USB stick?
    ... at least two pages of intricate command line stuff. ... The password is only used when you want to backup to a remote machine ... via the network, using the ssh protocol. ... (e.g. with linux, ...
    (sci.electronics.design)
  • Re: Ssh/Rsh problems
    ... > I am encountering problems with both ssh and rsh, ... > When I attempt to run a command on a remote machine via ssh, ...
    (comp.os.linux.security)
  • Re: I do not get ssh. Why is it more secure?
    ... How is this any more secure that plain old telnet? ... And, well, I just don't get the advantage of ssh ... If you put your ssh server on port 12345, it will be free from attacks. ... SSH connections, in the hands of someone who actually knows what they are doing, have the benefit of treating a remote machine as a remote machine. ...
    (comp.os.linux.misc)
  • Re: Remote Execution Through FTP
    ... > I need to send some file from my local machine to a remote machine ... > generation mechanism in SSH. ... then you can script this quite easily using public key's to authenticate. ... Make sure the permissions on the .ssh directory and all the files in it are ...
    (comp.unix.admin)
  • problem about executing a command without remote shell
    ... I want to execute a command on the remote machine with ssh client, ... But if I first login into the remote machine and then execute the same ...
    (comp.security.ssh)