0

Please help me out, as I'm trying to execute 'rm -Rf' and 'ln -s' on a bunch of servers through 'ssh -i' and somehow symlink fails, although running directly on servers works...

$ ssh -i ~/.ssh/id_rsa www@web1 '
    rm -Rf /home/www/system && 
    ln -s /home/www/framework/system /home/www/system'
ln: creating symbolic link `/home/www/system' to `/home/www/framework/system': No such file or directory

Here is what I see on the remove server for path /home/www/framework:

$ ls -al
total 32
drwxr-xr-x  5 www www 4096 2011-04-26 09:21 .
drwxr-xr-x  5 www www 4096 2011-06-03 11:25 ..
-rw-r--r--  1 www www 2547 2011-04-26 09:21 license.txt
drwxr-xr-x  8 www www 4096 2011-04-26 09:21 system
sehe
  • 374,641
  • 47
  • 450
  • 633
eistrati
  • 2,314
  • 6
  • 26
  • 35
  • it would appear that the www user is potentially jailed (for security reasons) and cannot see the mountpoint that /home/www/framework/system is bound to. Also, any kind of `rm -Rf` over ssh is hardly a good practice – sehe Jun 07 '11 at 21:04
  • Thank you! I'll work on `rm -Rf`, meanwhile can you please give some guidelines where should I look to enable symlinking over ssh? I'd really appreciate the effort! – eistrati Jun 07 '11 at 21:11
  • You should instead find out, why it is not working :) You could see what /proc/PID/root is pointing to; In fact, `sudo ls -ltrad /proc/*/root | rev | sort -r | rev` could be a quick way to find out any `chrooted` processes. Run it outside the ssh session, on the server box, while the ssh session is connected – sehe Jun 07 '11 at 21:23
  • Also, are you using the same user (`www`) over ssh as locally? You might simply not have permission to traverse the root. Try `ln -s ./framework/system ./system` in the homedir instead – sehe Jun 07 '11 at 21:25

1 Answers1

1

Problem solved! This is sooo weird, but basically when I did ssh -i ~/.ssh/id_rsa www@web1 'rm -Rf /home/www/system; ln -s /home/www/framework/system /home/www/system', it worked!!!

eistrati
  • 2,314
  • 6
  • 26
  • 35