Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was using the GUI version of Transmission for Ubuntu. When my torrents were downloaded I ran the following script as user server with the corresponding ssh keys:

#!/bin/bash

cd "/home/server/Downloads"
find . -type f | while IFS= read filename; do
case "${filename,,*}" in
*.part) : ;; # Excludes *.part files from being moved
*.resume) : ;;
*.torrent) : ;;
*.trashinfo) : ;;
move.sh) : ;;
# Include
*document*) scp "$filename" "imac@imac.local:/users/imac/Documents/" ;;
# Else
 *) echo "Don't know where to put $filename" ;;
esac
done

Now I'm using transmission-daemon and the script is not executed as server anymore, therefore, scp does not work because when trying to ssh to imac@imac.local it prompts for a password (no ssh key for that user).

How can I fix this problem?

share|improve this question

1 Answer 1

If you have read access to "server" private ssh key, use the -i modifier with scp, that tells it to use a specific private key file.

BTW, isn't shorter to write this?

find /home/server/Downloads -type f -iname *document* -exec scp -i pathtokeyfile "{}" "imac@imac.local:/users/imac/Documents/" ;
share|improve this answer
    
Thanks, that did help. The problem is that transmission-daemon is not running the script as root. I logged the user with "echo "$USER" >> $LOG_FILE" and it returns an empty log file. If I run it as server or root it returns the corresponding user. –  fedxc Nov 11 '11 at 1:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.