You are not logged in.
Pages: 1
I've got a very strange problem I cannot solve.
I have set unison to synchronize my laptop (mercure) against my home computer (jupiter). It works really fine.
I can run it from the terminal:
unison -batch CERTES
and it runs good.
I have set ssh keys so that id doesn't ask me for a password. And that runs fine too because if I do ssh to jupiter, I log in without any password.
That's what the unison profile looks like:
[jordi@mercure ~]$ cat .unison/CERTES.prf
root = /home/jordi/CERTES
root = ssh://jordi@192.168.7.2//home/jordi/Macbook
After this, everything is ok.
Then I set a cron job so this is done once an hour everyday using crontab -e:
0 * * * * /usr/bin/unison -batch CERTES
And every hour I receive this mail:
Contacting server...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
Fatal error: Lost connection with the server
Ok then, this seems like cron can't log into jupiter with ssh as I thought. So I modify /etc/ssh/sshd_config to put this option:
PermitUserEnvironment yes
I do the same on mercure, even if I think it's useless, but...
I always receive the same error and I can't get the 2 folders synchronzed.
Before my hard drive crashed a week ago, I had unison running by cron and it was working nice, but now I'm unable to do it again...
Does anyone has a clue about what's happening and how to solve it?
Last edited by jcerdan (2008-07-04 09:52:00)
Offline
Sounds like your environment isn't being set properly...
Have you tried putting it in to a bash script, then running the script from cron?
#!/bin/bash
/usr/bin/unison -batch CERTES
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
I have just tried this and it does not work. I receive the same error. Yes I think also that the problem is inssh config, but in the unison FAQ they just talk about PermitUserEnvironment variable set to "yes".
I really don't know how to solve this. Is there a kind of test that would help me discover what's happening?
Offline
Okay, I tried to run unison under root and I receive the same errors.
So It's clear that crontab is trying to run under root environment and not under the user one. I feel like I am very close to solve this problem!
Offline
Leave the script running under your username, and add this line to the script after the #!/bin/bash line:
source /home/YOURUSERNAME/.bash_profile
source /home/YOURUSERNAME/.bashrc
That should ensure your environment is setup properly I hope. Your PATH or some other environment variable probably isn't being set correctly in the non-interactive shell (cron) whereas it does get set correctly in the interactive shell (your login).
If that still doesn't work, can you post the output of the `env` command?
If you put this in your crontab:
env | mail -s "env output" your email@address.com
you will get a list of the environment variables in the non-interactive shell e-mailed to you. Then you can compare that to the output from just typing in manually and seeing what the difference is, and if there's something missing.
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
I have tried adding source to the crontab but I got the same error.
This is the env output from cron:
CONSOLE=/dev/console
SHELL=/bin/sh
CMDLINE=root=/dev/disk/by-uuid/25d2ee78-61ac-4b43-929a-28180b156786 ro
TERM=linux
rootdelay=0
USER=jordi
INIT_VERSION=sysvinit-2.86
ro=y
PATH=/bin:/usr/bin:/sbin:/usr/sbin
_=/usr/bin/env
RUNLEVEL=3
PWD=/home/jordi
PREVLEVEL=N
root=/dev/disk/by-uuid/25d2ee78-61ac-4b43-929a-28180b156786
SHLVL=3
HOME=/home/jordi
kinit_params= rootfstype=ext3 rootdelay=0
And this is the env output from the terminal:
[jordi@mercure ~]$ env
XDG_DATA_HOME=/home/jordi/.local/share
SHELL=/bin/bash
TERM=xterm
DESKTOP_STARTUP_ID=
HISTSIZE=1000
QT_XFT=true
GTK_RC_FILES=/etc/gtk/gtkrc:/home/jordi/.gtkrc-1.2-gnome2
WINDOWID=54526543
QTDIR=/opt/qt
GTK_MODULES=gnomebreakpad
USER=jordi
GNOME_KEYRING_SOCKET=/tmp/keyring-C1rLTl/socket
SSH_AUTH_SOCK=/tmp/keyring-C1rLTl/ssh
KDEDIR=/opt/kde
OOO_FORCE_DESKTOP=gnome
SESSION_MANAGER=local/mercure:/tmp/.ICE-unix/3449
USERNAME=jordi
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins:/opt/mozilla/lib/plugins
XDG_CONFIG_DIRS=/etc/xdg:/opt/kde/etc/xdg
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/java/jre/bin:/opt/kde/bin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/opt/qt/bin
DESKTOP_SESSION=gnome
GDM_XSERVER_LOCATION=local
INPUTRC=/etc/inputrc
PWD=/home/jordi
JAVA_HOME=/opt/java/jre
LIBXCB_ALLOW_SLOPPY_LOCK=true
EDITOR=vi
LANG=es_ES.utf8
GNOME_KEYRING_PID=3448
GDM_LANG=es_ES.utf8
KDEDIRS=/opt/kde:/usr
PS1=[\u@\h \W]\$
PS3=>
GDMSESSION=gnome
PS2=>
HISTCONTROL=erasedups
SHLVL=1
HOME=/home/jordi
PS4=+
XDG_CONFIG_HOME=/home/jordi/.config
GNOME_DESKTOP_SESSION_ID=Default
XDG_CACHE_HOME=/home/jordi/.cache
LOGNAME=jordi
LESS=-R
CLASSPATH=:/opt/java/jre/lib
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-5ncgDqnWoO,guid=1e082c45cdb24be2d415016e486c820b
XDG_DATA_DIRS=/usr/share:/usr/local/share:/usr/local/share/:/usr/share/:/usr/share/gdm/:/opt/kde/share
PKG_CONFIG_PATH=:/opt/kde/lib/pkgconfig:/opt/qt/lib/pkgconfig
WINDOWPATH=7
DISPLAY=:0.0
J2REDIR=/opt/java/jre
G_BROKEN_FILENAMES=yes
COLORTERM=gnome-terminal
XAUTHORITY=/home/jordi/.Xauthority
_=/usr/bin/env
A lot of vars are different, but they refer to the Gnome environment. I can see that SHELL, TERM are different, but I don't know what can make the difference.
Do you think there's a problem there?
Offline
There's some SSH stuff in there too, which might be stuffing you up, and generally a lot of stuff that it different which looks like is because cron is running your script under /bin/sh whereas when you run it, it's running under /bin/bash
I'm not 100% what the 'correct' way to fix that is. I'd probably try something like this, at least for testing to see if that is the issue:
# mv /bin/sh /bin/sh.ORIGINAL
# ln -s /bin/bash /bin/sh
That will substitute /bash for sh, although I'm not sure if bash will behave differently when called as /bin/sh instead of /bin/bash
(Edit: I'm AFK for the next 7 days, so hopefully someone else can jump in an help you from here)
Last edited by fukawi2 (2008-07-03 23:45:04)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
I solved it!!! Hurrah!
You (fukawi2) gave me the idea to have a look again to the ssh config. I found that my ssh keys had a passphrase...I really don't remember me setting a passphrase but..
Furthermore, as this passphrase is not asked on ssh terminal (because gnome unblocks the keys repository on login), I wasn't suspecting this!
well, now unison synchronises good!
Thanks a lot for your interest and help Fukawi2.
Jordi.
Offline
You're welcome
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Pages: 1