Cron using shh keys fail

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Cron using shh keys fail
# 1  
Old 10-09-2016
Cron using shh keys fail

Hi All,

Hoping someone can help with something I'm sure is an easy fix. I'm trying to setup a cron to ssh to a server and check if a process is running. I've got keys setup from the jumpbox which I'm originating the check from (I don't have root privileges), when running the check manually from the just box it has no issue logging works perfectly however when logging in during the cron process it fails. It keeps prompting with the below

Code:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).

I'm just using the standard ssh login string in the cron

Code:
ssh user1@10.0.2.1

Could anyone advise if they have any expierence with this. I mean i know the keys work as its fine when doing it from my shell.

Thanks

Last edited by rbatte1; 10-10-2016 at 11:06 AM.. Reason: Spelling corrections
# 2  
Old 10-09-2016
This is untested: cron provides a very limited environment, so ssh may fail to find the keys file in ~/.ssh. You can try to run ssh in verbose mode by adding one or more -v options.
# 3  
Old 10-10-2016
Are the keys passphraseless? It looks to me as though ssh is waiting on the passphrase then goes to password. If the keys are loaded into an ssh session on the just box you won't need to enter the passphrase when running the script manually, but the cron job will not be running in that session.

Andrew
# 4  
Old 10-10-2016
Quote:
Originally Posted by mutley2202
I'm just using the standard ssh login string in the cron

Code:
ssh user1@10.0.2.1

In addition to what the others already pointed out: it might be that your connection needs a terminal and doesn't have one from the cron-initiated session. If you want to use ssh as a sort of rexec-replacement, you might want to do it this way:

Code:
ssh -nqo 'BatchMode = yes' "<user>@<host>" "<your-command>"

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. Shell Programming and Scripting

Why does my test fail ??

Hello, I am stuck... i dunno why does my test fail... any idea ? #!/bin/bash dos2unix info.txt Distor=Distributeur LINE=$(cat info.txt | sed -n 1p) echo $LINE echo $Distor echo "" echo "123-$LINE-123" echo "123-$Distor-123" if ; then LINE2=$(cat info.txt | sed -n 2p) echo $Distor... (14 Replies)
Discussion started by: patx
14 Replies

3. Shell Programming and Scripting

What are public keys in ssh and how do we create the public keys??

Hi All, I am having knowledge on some basics of ssh and wanted to know what are the public keys and how can we create and implement it in connecting server. Please provide the information for the above, it would be helpful for me. Thanks, Ravindra (1 Reply)
Discussion started by: ravi3cha
1 Replies

4. Shell Programming and Scripting

fail on comparison

Hi Am having 2 files. I have one data file. before inserting in to the table am taking cout of the data file and store as data 1. After insert in to the table and am taking the count from the table and store as data2. If i try to compare those values If then echo "data match"... (5 Replies)
Discussion started by: bobprabhu
5 Replies

5. UNIX for Dummies Questions & Answers

Help connecting to linux server from shh client in windows!

I just installed the latest version of unbuntu server and want to connect from windows using a ssh client. This is my first linux server, so bare with me =) For my server... cat /etc/hostsgives me 127.0.0.1 localhost 127.0.1.1 ubuntuHomeI tried using ssh secure shell and putty in vista.... (11 Replies)
Discussion started by: Bandit390
11 Replies

6. UNIX for Advanced & Expert Users

Notify Me when job fail using cron

I would like to be notified when an Informix dbexport job fails on a TRU64 system. My idea is to send an email via telnet, but can only get telnet to do it interactively. I can do the following steps on my UNIX box interactively, but cannot send an email with a script. Can someone help? Is there... (3 Replies)
Discussion started by: ejaggers
3 Replies

7. AIX

AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log

Hi, I can use 'crontabs –e' and do all the scheduling I like. However I would like to auto send myself just the cronjobs logs that fail. That is to say the PIDs that fail and the related lines with those PID’s only. (Not the full set of logs) Has anyone done this work? Or does an AIX 5.3 tool... (0 Replies)
Discussion started by: Keith Johnson
0 Replies

8. UNIX for Advanced & Expert Users

shh authorization problem

I have ssh setup on 2 boxes ( aix / linux ). building a batchjob i have made a plaintext key. I force the command in the authorized_keys file running from aix -> linux ssh -i ~/.ssh/batchkey user@remote works perfect but from linux -> aix it get the following debug1:... (1 Reply)
Discussion started by: progressdll
1 Replies

9. UNIX for Dummies Questions & Answers

arrow keys / special keys

how to use the arrow keys in shell scripting. is there any special synatax / command for this. i just want to use the arrow keys for navigation. replies appreciated raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies

10. UNIX for Advanced & Expert Users

cron fail to run

Hi, Does anyone know why the cron job fail to run automatically ? We have the problem with some Solaris 2.5.1 Machine ! The cron seemd to fail to submit the jobs defined at the defined time !! Why ? Sometime it runs OK,but sometime it fail . We are very sure the problem is due to... (6 Replies)
Discussion started by: kerwin_hsu
6 Replies
Login or Register to Ask a Question