Hey Everyone,
I’ve STTF, but I can’t seem to find the cause of a problem I’m having. I’m trying to automate the following scp command vi cron.
This is a bone stock install of Opensuse, with only the keys having been generated.
Here’s my command (with private info changed):
/usr/bin/scp -i /home/myusername/.ssh/id_rsa -P 1234 myftpname@mydestination.com:/home/myftpname/Back1tUp/* /home/myusername/backups/
This works great from command line, great from my script, but when I put it in my crontab (using crontab -e), It fails. I have tried putting it in the root crontab and doing:
su - myusername -c /home/me/myscript.sh >>logfile
That fails too.
When I put my scp command in verbose logging mode, Here’s the difference between the good version (run from command line), and the automated version (cron)
GOOD:
ebug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key:
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 149
debug2: input_userauth_pk_ok: fp 40:<redacted>:fb
debug3: sign_and_send_pubkey
debug1: Authentication succeeded (publickey).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
BAD:
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/myusername/.ssh/id_rsa
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: read_passphrase: can’t open /dev/tty: No such device or address
debug2: no passphrase given, try next key
debug1: Trying private key: /home/myusername/.ssh/id_dsa
debug3: no such identity: /home/myusername/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
Here are some things I have added to help correct the problem:
export HOME="/home/myusername"
. /home/myusername/.profile
. /home/myusername/.env
Sorry for the long post, but thanks in advance for your help!