0

I've set anacron under the non-root user as follows:

mkdir ~/.anacron
cd ~/.anacron
mkdir cron.daily cron.weekly cron.monthly spool etc

My anacrontab in ~/.anacron/etc:

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/zimmi/bin
HOME=/home/zimmi
LOGNAME=zimmi

1 5  daily-cron nice run-parts --verbose /home/zimmi/.anacron/cron.daily
7 10 weekly-cron nice run-parts --verbose /home/zimmi/.anacron/cron.weekly
@monthly 15 monthly-cron nice run-parts --verbose /home/zimmi/.anacron/cron.monthly

In ~/.anacron/cron.daily there's a symlink to a simple bash script:

#!/bin/bash

workdir='/home/zimmi/documents/zimmi/dizertace/social'
logfile=$workdir/restart-gear.log
date >> $logfile

{
HOME=/home/zimmi
cd $workdir && \
echo $USER && \
ls ~/.ssh && \
git merge origin/master && \
git commit --allow-empty -m "Restart gear" && \
git push && \
echo "Success" ; } >> $logfile 2>&1

When run, it outputs the following:

St lis 18 15:29:11 CET 2015
zimmi
config
id_rsa
id_rsa.pub
known_hosts
openshift
openshift.pub
Already up-to-date.
[master 6658dd1] Restart gear
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have no idea why as I don't have any more output (except for mail saying run-parts: /home/zimmi/.anacron/cron.daily/restart-gear exited with return code 128).

I've put the following code into my .zprofile (using zsh as default shell).

rm -f $HOME/.anacron/anacron.log
/usr/sbin/anacron -t /home/zimmi/.anacron/etc/anacrontab -S /home/zimmi/.anacron/spool &> /home/zimmi/.anacron/anacron.log

When I run this piece of code directly, the whole process works just fine.

UPDATE

ssh -vvv log

OpenSSH_6.7p1 Ubuntu-5ubuntu1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/zimmi/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug2: ssh_connect: needpriv 0
debug1: Connecting to social-zimmi.rhcloud.com [52.21.29.138] port 22.
debug1: Connection established.
debug1: identity file /home/zimmi/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/zimmi/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "social-zimmi.rhcloud.com" from file "/home/zimmi/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/zimmi/.ssh/known_hosts:23
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: setup [email protected]
debug1: kex: server->client aes128-ctr [email protected] none
debug2: mac_setup: setup [email protected]
debug1: kex: client->server aes128-ctr [email protected] none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1524/3072
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7
debug3: load_hostkeys: loading entries for host "social-zimmi.rhcloud.com" from file "/home/zimmi/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/zimmi/.ssh/known_hosts:23
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "52.21.29.138" from file "/home/zimmi/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/zimmi/.ssh/known_hosts:24
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'social-zimmi.rhcloud.com' is known and matches the RSA host key.
debug1: Found key in /home/zimmi/.ssh/known_hosts:23
debug2: bits set: 1504/3072
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/zimmi/.ssh/id_rsa (0x7f12300e1d20),
debug2: key: /home/zimmi/.ssh/id_dsa ((nil)),
debug2: key: /home/zimmi/.ssh/id_ecdsa ((nil)),
debug2: key: /home/zimmi/.ssh/id_ed25519 ((nil)),
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/zimmi/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /home/zimmi/.ssh/id_dsa
debug3: no such identity: /home/zimmi/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/zimmi/.ssh/id_ecdsa
debug3: no such identity: /home/zimmi/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/zimmi/.ssh/id_ed25519
debug3: no such identity: /home/zimmi/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

What am I doing wrong here?

4
  • Run ssh -v host exit in your script, and post the result Nov 18, 2015 at 14:59
  • ssh -vvv host exit would be more helpful. And run it please with the context of the user who is starting the cron task.
    – Jakuje
    Nov 18, 2015 at 15:13
  • Will post asap, meanwhile just noticed these lines in syslog. Maybe anacron being run once as a root and once as current user? Nov 18 16:38:40 cm-zimmi anacron[1488]: Will run job daily-cron' in 5 min. Nov 18 16:38:45 cm-zimmi anacron[2111]: Anacron 2.3 started on 2015-11-18 Nov 18 16:38:45 cm-zimmi anacron[2111]: Job daily-cron' locked by another anacron - skipping Nov 18 16:38:45 cm-zimmi anacron[2111]: Normal exit (0 jobs run) Nov 18, 2015 at 15:40
  • updated the question with ssh debug3 output Nov 18, 2015 at 15:48

1 Answer 1

0

Hmm... seems to be working now. Here's what I did:

  • changed ssh key from openshift to default id_rsa
  • added a new item to ~/.ssh/config

One of those two helped. Don't know why though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .