Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


sftp: unrecognized option: -


With a sftp script like the following one, I get a deployment faillure/

 - pipe: atlassian/sftp-deploy:0.5.8
DEBUG: 'true'
USER: 'wwwuser'
SERVER: '<servername>'
REMOTE_PATH: '<path>'
EXTRA_ARGS: "--exclude='.*'"


In the logs this is the sftp command that's generated. The empy '-' is the cause of the problem, but I can't find how to remove it.

sftp -b - -rp -v '--exclude='\''.*'\''' wwwuser@<servername>:<path>

3 answers

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 12, 2023

Hi @Rob Buijs

Thank you for your question!

Found this discussion and I'll try to help.

1. The empty '-' in the SFTP command is not an issue, pipe use it as part of -b option:

man sftp

-b batchfile
Batch mode reads a series of commands from an input batchfile instead of stdin. Since it lacks user interaction it should be used in conjunction
with non-interactive authentication to obviate the need to enter a password at connection time (see sshd(8) and ssh-keygen(1) for details).

A batchfile of ‘-’ may be used to indicate standard input. sftp will abort if any of the following commands fail: get, put, reget, reput, rename,
ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd, df, symlink, and lmkdir.

Termination on error can be suppressed on a command by command basis by prefixing the command with a ‘-’ character (for example, -rm /tmp/blah*).
Echo of the command may be suppressed by prefixing the command with a ‘@’ character. These two prefixes may be combined in any order, for example
-@ls /bsd.

2. The root cause for the error 

sftp: unrecognized option: -


EXTRA_ARGS: "--exclude='.*'"

that you try to pass into sftp, but sftp supports only:


usage: sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher]

          [-D sftp_server_path] [-F ssh_config] [-i identity_file]

          [-J destination] [-l limit] [-o ssh_option] [-P port]

          [-R num_requests] [-S program] [-s subsystem | sftp_server]



So, to have ability to exclude files you could use an alternative pipe:


Example with an EXTRA_ARGS to exclude all files with '.txt' extension from deploy.

  - pipe: atlassian/rsync-deploy:0.10.1
      USER: 'ec2-user'
      SERVER: ''
      REMOTE_PATH: '/var/www/build/'
      LOCAL_PATH: 'build'
      DEBUG: 'true'
      EXTRA_ARGS: '--exclude=*.txt'

CC: @Beau Liddell @Ankit Gupta 

Best regards,
Oleksandr Kyrdan

I have a ssh key for that account, not a password. I tried with a fake password, just to see what happened:


+ echo -e '\e[37mDEBUG: Executing echo "mput /opt/atlassian/pipelines/agent/build/avada-child-theme" | sshpass -p blieb sftp -o PubkeyAuthentication=no -rp -v --exclude='\''.*'\'' wwwuser@<server>:<path>\e[0m'
error remains the same:
sftp: unrecognized option: -

@Rob Buijswere you able to get this resolved? I'm facing the exact same issue.

No, we never resolved this issue. We worked around it with scp

Hi Rob,

You can try setting the PASSWORD variable for the pipe.

As per the code:

In case the $PASSWORD var isn't defined, the other sftp cmd is triggered (which leads to error for you). Its possible the cmd doesn't work with PASSWORD based servers 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events