What Does –– (double dash) Mean In SSH Shell Command?

I see lots of seasoned admins and cloud provider wrapper scripts use ssh client command as follows in shell:

ssh nixcraft@server1.cyberciti.biz --

What the double -- (dash) does here? Why it is used in this shell command and why not just use the following?

ssh nixcraft@server1.cyberciti.biz

Tutorial details
Difficulty Easy (rss)
Root privileges No
Requirements None
Time N/A
The double dash “--” means “end of command line flags” i.e. it tells ssh command not to try to parse what comes after command line options. You will see something as follows when you use gcutil ssh vmNameHere python wrapper. It will display and execute ssh as follows:

ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/vivek/.ssh/google_compute_engine -A -p 22 nixcraft@server1.cyberciti.biz --

This syntax ensures that you can run commands on the remote server without ssh parsing them:
ssh nixcraft@server1.cyberciti.biz -- command1 --arg1 --arg2

The above syntax tell ssh not try to parse --arg1 and --arg2 after -- command line options. This ensures that command1 will accept --arg1 and --arg2 as arguments.

## safe examples ##
ssh nixcraft@server1.cyberciti.biz -- --commandName --arg1 --arg2

This kind of behavior is mostly defined and handled by the ssh command and not by your bash/ksh/csh shell. This is also true for many other commands. For example you can not create or view a file named --file or -f using cat command

## fail ##
cat --file
cat -f

Instead try passing double dash “--” to instruct cat command not to try to parse what comes after command line options:

## works ##
cat -- --file
cat -- -f
See also

You may also want to read the following faq:

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • OJay Dec 3, 2013 @ 8:00

    Interesting stuff! Didn’t know that that option existed. It’s great to see something new here from time to time even after so many years :-)

  • Bobsleer Feb 4, 2014 @ 11:30

    Thanx for the info.
    Where can one find documentation/manual about this double-dash argument?
    (maybe in POSIX?)

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.