1 # $OpenBSD: sftp-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
2 # Placed in the Public Domain.
11 SRC=`dirname ${SCRIPT}`
14 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
18 start_sshd -oForceCommand="internal-sftp -d /"
20 # Remove Port and User from ssh_config, we want to rely on the URI
21 cp $OBJ/ssh_config $OBJ/ssh_config.orig
22 egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
24 verbose "$tid: non-interactive fetch to local file"
26 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed"
27 cmp ${DATA} ${COPY} || fail "corrupted copy"
29 verbose "$tid: non-interactive fetch to local dir"
32 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed"
33 cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
35 verbose "$tid: put to remote directory (trailing slash)"
37 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b - \
38 "sftp://${USER}@somehost:${PORT}/${DIR}/" > /dev/null 2>&1 << EOF
44 fail "sftp failed with $r"
46 cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
49 verbose "$tid: put to remote directory (no slash)"
51 ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b - \
52 "sftp://${USER}@somehost:${PORT}/${DIR}" > /dev/null 2>&1 << EOF
58 fail "sftp failed with $r"
60 cmp ${DATA} ${DIR}/copy || fail "corrupted copy"