passphraseless access to rsync with ssh through cron fails

I have setup ssh keys without a passphrase (Ubuntu) and copied them to my remote server (Centos6). I can login with ssh without a password successfully under my username.

When I execute the following script in a terminal under my username (not root) it works. When I execute it through cron under my user name it fails with response:

Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 

Here is the script:

#!/bin/bash export PATH=/home/<username>/git/kodi-playercorefactory/bash-scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin rsync -rvzO  -e 'ssh -p 6135 -i /home/<username>/.ssh/id_rsa.pub' <username>@xx.xxx.xx.xx:<filename> <filename> 

Any help will be greatly appreciated

Replay

The -i option of ssh is supposed to input the file name that contains the private key, not public key. But you have presumably given the file name containing the public key, given by the name /home/<username>/.ssh/id_rsa.pub.

Assuming the private key is in /home/<username>/.ssh/id_rsa, the following should work:

rsync -rvzO  -e 'ssh -p 6135 -i /home/<username>/.ssh/id_rsa' <username>@xx.xxx.xx.xx:<filename> <filename>

Category: ssh Time: 2016-07-28 Views: 0
Tags: ssh rsync cron

Related post

  • Rsync with ssh and root not working after change hosts IP 2015-10-20

    We have a server that backup multiples servers. The backups server is located in the office and all other server in the cloud. We have moved all the server to a new IP, and from this moment the backups stopped. . In the hosts we have authorized the n

  • Rsync with SSH prompting for remote password 2015-10-31

    I have followed the following guide to setup Rsync with SSH between my local machine and a remote server: I performed the below as root: rsync -avz -e ssh /home/user/dir [email protected]::Backup/dir -> prompts for password ssh-keygen -> Key gener

  • How do I access my server with SSH? 2010-09-01

    My computer runs Windows 7 and my server runs Linux CENTOS 5.5. What software do I need on my W7 machine to access my server with SSH? --------------Solutions------------- Putty SSH client. ALternatively if you prefer working in a UNIX like environme

  • Mount a filesystem (using FUSE) with SSH through two computers 2012-08-10

    Possible Duplicate: How to mount remote SSHFS via intermediate machine? Tunneling? I can mount a filesystem over SSH directly with $ sshfs hostname: mountpoint However, in order to access a certain machine from an outside network, I must SSH through

  • accessing a server via SSH through ilo - dumping information/current state 2015-08-02

    I'm having to frequently access servers via ilo - ssh only, no web interface. Am I meant to be able to bring a server back up through just this tool? Or utilize others like ipmtool to be able to do things? Similarly when the server's stuck in boot, h

  • How to avoid the Load in rsync with ssh? 2012-01-20

    I having an large amount of data (300GB) in an Linux server. Now, i want to transfer to another Linux server using the rsync over ssh. When i transferring the data it creating huge load in the server. May i know how to avoid the load in the server wh

  • Access remote server with Nautilus through double SSH tunnel 2010-06-09

    I'm trying to access my work computer from home. We are supposed to SSH into a server, say ssh.company.com and from there ssh into an xhost to to work, say xhost04.company.com. xhost04 is not directly accessible. How can I browse files on xhost04 fro

  • Access remote server with Nautilus through double SSH tunnel using SSHFS 2010-07-20

    I'm trying to access my work computer from home. We are supposed to SSH into a server, say ssh.company.com and from there ssh into an xhost to to work, say xhost04.company.com. xhost04 is not directly accessible. How can I browse files on xhost04 fro

  • Rsync with ssh-keygen to ssh user with limited commands and specifc directory 2011-12-23

    I have two machines, local and remote. I want to back up my files and folders to the remote machine automatically, using rsync to transfer files and folders, using ssh-keygen to automatically log into the remote machine. I can do this as ssh root, bu

  • RSync over SSH hangs and fails with timeout 2012-03-18

    Client: Gentoo, GCC 4.3.4, RSync 3.0.9 Server: Ubuntu 10.04.4 LTS, RSync 3.0.7 Client and server connectet through is Internet, about 2Mbps. Ping is ok. RSync called on any files in any direction hangs on random file, then, after timeout, fails with:

  • How to disable sftp access to user with ssh already disabled (user shell = /bin/false, but connection still works with sftp) 2016-02-08

    In sshd_config, by default, login is allowed for all groups and users. The allow/deny directives are processed in the following order: DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups. (found in the man page). So, I have to configure the se

  • Dropbear equivalent to rsync with ssh proxy command 2015-06-18

    I am trying to guess the dropbear equivalent to this regular rsync command (using ssh with a proxy) rsync -avz --delete -e "ssh -o 'ProxyCommand ssh [email protected] exec nc %h %p 2>/dev/null'" /tmp/a-folder [email protected]:/tmp According to my searc

  • Problems accessing EC2 instance with SSH key pair 2012-04-26

    Just set up a new EC2 instance, downloaded the pem file and currently cannot get into the box. I'm using the command... $ ssh -i .ssh/key.pem [email protected]***.eu-west-1.compute.amazonaws.com ...and being asked for a passphrase. I didn't assi

  • Able to access the server with SSH, but not with SFTP 2014-03-11

    I have access to the server via SSH (using Putty Client), but I am not able to connect via SFTP, using same port (using FileZilla, or other clients). Server requires public key authorization, and keys are configured properly in all clients. What migh

  • PuTTY won't connect with SSH - Password authentication failed 2013-07-10

    I try to connect to a remote machine through SSH. It works great using SSH from a Linux Machine. But from PuTTY on a Win7 I always get a "Password authentication failed". In the auth.log of the remote machine I see the failed password logs but I

  • Attempting to Update with Yum through Terminal Fails 2015-06-11

    Since upgrading to Fedora 22, I have had an issue with updating using yum through the Terminal. Whenever I run the sudo yum update command, this happens every time: What's the matter? What can I do to fix it? --------------Solutions------------- Sear

  • How to Setup Rsync without password with SSH on UNIX / Linux? 2013-02-22

    How can I set up a rsync between two hosts without providing any password? --------------Solutions------------- Below is the article from The Geek Stuff 1. Test rsync over ssh (with password): Do a rsync to make sure it asks for the password for your

  • How to use rsync with a remote remote host 2012-07-15

    I am a happy user of rsync -e ssh and use it to synchronize data between my machine and a remote host using rsync -avz -e ssh [email protected]:~/folder ~/folder And this did what I needed until now. I am now working with a configuration where the access is a

  • Putty works but ssh from terminal fails after SSH2_MSG_KEXINIT 2011-09-07

    I have had problems connecting with ssh through the terminal to different machines around my workplace and my home. The three last lines is (if I run ssh with -vvv): debug3: load_hostkeys: loaded 0 keys debug1: SSH2_MSG_KEXINIT sent Read from socket

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 1.142 (s). 13 q(s)