Problems with ssh and cron

From: Robert Nickel (Robert_Nickel_at_bigfoot.com)
Date: 10/20/04


Date: Wed, 20 Oct 2004 13:56:19 +0200

Hi there,

I have successfully established a public-private-key connection from a
RedHat Linux machine to a remote server via ssh. The remote username is
rnickel, my local is robert. So, as user "robert" I can type

scp ~/tmp/* rnickel@remote:

and everything works fine without passphrase-prompt.

When running the same thing from a cron job (either from my own crontab
or from /etc/crontab as user robert) I get the error message

Permission denied (publickey).

(for my own crontab I have typed "crontab -u robert -e")
Can you tell me what the problem could be?

Thanks in advance

Robert Nickel

Here is my script and the corresponding output:

SCRIPT:
#!/bin/bash

#
# copy files to remote
#
echo I am $USER from $HOSTNAME
scp -i /home/robert/.ssh2/identification /tmp/* rnickel@remote:
rm /tmp/robert/*

OUTPUT (with verbose):
I am robert from baker.math.tu-cottbus.de
Executing: program /usr/bin/ssh host remote, user rnickel, command scp
-v -t .
OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Rhosts Authentication disabled, originating port will not be
trusted.
debug1: Connecting to remote [141.43.65.25] port 22.
debug1: Connection established.
debug1: identity file /home/robert/.ssh2/identification type -1
debug1: Remote protocol version 2.0, remote software version 3.2.9.1 SSH
Secure Shell (non-commercial)
debug1: no match: 3.2.9.1 SSH Secure Shell (non-commercial)
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.6.1p2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'remote' is known and matches the DSA host key.
debug1: Found key in /home/robert/.ssh/known_hosts:2
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/robert/.ssh2/identification
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: Next authentication method: password
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
debug1: Calling cleanup 0x8062d00(0x0)
lost connection



Relevant Pages

  • Are remote pipes fixed in 3.5?
    ... > and ssh will never return. ... SSH2 will shut down the channel without telling the ... > remote side that stdout has closed. ... > debug1: channel request 0: exec ...
    (SSH)
  • Are remote pipes fixed in 3.5?
    ... SSH2 will shut down the channel without telling the ... remote side that stdout has closed. ... debug1: channel request 0: exec ...
    (SSH)
  • Re: OpenSSH to SSH2 scp.
    ... When checking the path on the remote host are you checking it under the user ... > I try to scp a file onto the remote server, I get an error message ... > debug1: channel 0: rcvd close ...
    (comp.security.ssh)
  • Re: bad command= option in ssh authorized_keys - success, but...
    ... sam wrote: ... >> detail about the failure of passwordless scp login. ... debug1: Remote: Port forwarding disabled. ...
    (comp.unix.bsd.freebsd.misc)
  • scp in unattended batch mode
    ... I'm wanting to set up a cron on a server to copy some backed up files ... from it to a remote server. ... Both of these are created in .ssh in the user's home directory, ... debug1: Reading configuration data /etc/ssh/ssh_config ...
    (comp.security.ssh)