Code Monkey home page Code Monkey logo

Comments (4)

dottedmag avatar dottedmag commented on July 3, 2024 1

My confusion stems from the following. SSH manpage documents that options can only be specified before the server name:

ssh [-tons of options here] destination [command [argument ...]]

I had a look at source hcloud server ssh code and indeed it appends the arguments to after the server name, and this I have confirmed by looking at process table:

hcloud server ssh <name> -v bash

runs

ssh -l root -p <ip> -v bash

which, I supposed, would try to run command -v on the remote server.

But apparently and unexpectedly OpenSSH client accepts options even after the server name, only -- stops its option processing. TIL, after 25 years of using SSH! Worth documenting, yes.

from cli.

phm07 avatar phm07 commented on July 3, 2024

You should already be able to just do this:

$ hcloud server ssh myserver -v

from cli.

dottedmag avatar dottedmag commented on July 3, 2024

Aha, and the command is delimited by --, I see, nice.

Should it be documented then?

from cli.

phm07 avatar phm07 commented on July 3, 2024

Aha, and the command is delimited by --, I see, nice.

Yes, this is the default behavior as described in the posix standard:

Guideline 10:
    The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.

And it is implemented by spf13/cobra, the CLI framework we use.

Should it be documented then?

Since this behavior is not unique to the hcloud CLI and we don't even implement it ourselves, I don't know if documenting it would make sense. This is how the documentation looks like right now:

Usage:
  hcloud server ssh [options] <server> [command...]

Flags:
  -h, --help          help for ssh
      --ipv6          Establish SSH connection to IPv6 address
  -p, --port int      Port for SSH connection (default 22)
  -u, --user string   Username for SSH connection (default "root")

I agree that it is not instantly apparent that you can pass flags to the ssh binary using the [command...].
Maybe something like this is better:

Usage:
  hcloud server ssh [options] <server> [ssh options] [command [argument...]]

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.