Вопрос

I'm trying to create a new launchagent file that will execute a shell script to perform a backup on an ftp folder. the content of the .plist file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.team.backup</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/jackm/Documents/Uni/backup.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <array>
    <dict>
    <key>Hour</key>
    <integer>15</integer>
    <key>Minute</key>
    <integer>30</integer>
    </dict>
    </array>
    <key>StandardErrorPath</key>
    <string>/Users/jackm/Documents/Uni/backup_err.log</string>
</dict>
</plist>

the backup.sh file is as follows:

#!/bin/bash
scp -r username@thehost.co.uk:/the/ftp/folder/      "/Users/jackm/morefolders/Backups/D2 Backup/$(date '+%d-%b-%H:%M')"

The backup.sh file runs absolutely fine when I execute via terminal, asks me for a password then downloads the folder. When using the launchd though, I do not even get prompted for a password, I just get the following in the error log file:

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

launchctl list gives the plist as having status 1. ~/etc/ssh_config PasswordConfirmation is 1 the .plist file is in the launchagents folder

Cheers

Это было полезно?

Решение

When run via launchd, your script doesn't have an interactive tty attached and thus cannot prompt for a password. You should set up public key authentication instead.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top