Skip to content

ssh: unable to use the -W argument #6381

Closed

Description

@ElDifinitivo

Describe the bug

I have a few hosts I connect to regularly through ssh that use the ProxyJump configuration, set up through ~/.ssh/config. It seems that any attempt to connect through them when nushell has been setup as a login shell will fail with the following error. Any other ssh connection of the ones I use regularly seem to work fine. Trying to connect to the same host through ssh through another shell, as nushell has been set to login, will also fail.

(HOST, PORT, and DESTINATION are obfuscated placeholders)

Error: nu::parser::unknown_flag (link)

  × The `exec` command doesn't have flag `-W`.
   ╭─[source:1:1]
 1 │ exec ssh -W '[HOST]:PORT' DESTINATION
   ·           ┬
   ·           ╰── unknown flag
   ╰────
  help: use exec --help for a list of flags

How to reproduce

  1. Set nushell as your login shell.
  2. Use ssh's ProxyJump configuration option in ~/.ssh/config or directly as a CLI argument with -W.

Expected behavior

Nushell should allow you to ssh to the destination.

Screenshots

No response

Configuration

key value
version 0.67.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-musl
rust_version rustc 1.61.0
cargo_version cargo 1.61.0
pkg_version 0.67.0
build_time 2022-08-18 03:10:01 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. kubouch commented on Aug 22, 2022

    @kubouch
    Contributor

    You need to wrap the -W in quotes, otherwise Nushell thinks it's a flag for exec.

  2. ElDifinitivo commented on Aug 22, 2022

    @ElDifinitivo
    Author

    And if it's set through a config option in .ssh/config? I use ProxyJump in tandem with an open ssh connection from a server behind a firewall where port 22 is not open, to a fully accessible server. This way I can connect to the locked-down server with my local ssh keys through the available server.

    ssh command given: ssh closed

    sample ssh config:

    Host open
        HostName <DOMAIN>
        User <USER>
    
    Host closed
        ProxyJump open
        HostName localhost
        Port <PORT>
        User <USERNAME>
    
  3. fdncred commented on Aug 22, 2022

    @fdncred
    Contributor

    maybe we should remove our exec command. it seems like it causes a bunch of confusion/trouble.

  4. kubouch commented on Aug 22, 2022

    @kubouch
    Contributor

    If there is no way to set the -W flag as "-W" you're likely out of luck. One thing you could try is hide exec before you call ssh.

    We need to realize the fall-through signatures to make exec usable, this is a prime use case for them. Removing exec until we have fall-through signatures might be a good idea.

  5. added
    A:external-commands
    on Aug 25, 2022
  6. dead10ck commented on Nov 17, 2022

    @dead10ck
    Contributor

    This issue is making ssh unusable with a ~/.ssh/config, as our ssh configs at work must proxy jump through a bastion host, and with a ~/.ssh/config, you don't have control over the args. It's a hard blocker for using nushell as a daily driver.

  7. fdncred commented on Nov 17, 2022

    @fdncred
    Contributor

    @dead10ck did you try hide exec from within nushell? I believe this would force nushell to use the OS's exec instead of nushell's version.

  8. dead10ck commented on Nov 18, 2022

    @dead10ck
    Contributor

    @fdncred yes, I tried that, and it still fails with the same error.

  9. dzintars commented on Nov 22, 2022

    @dzintars

    You can use

    Host target
      HostName target.host.tld
      # ProxyJump jump.host.tld
      ProxyCommand ssh '-W' '[target.host.tld]:22' jump.host.tld
    

    Instead of using ProxyJump you can use explicit ProxyCommand.
    But I still see this as a workaround, not an solution.

    #2675

  10. dead10ck commented on Nov 22, 2022

    @dead10ck
    Contributor

    @dzintars yes, I got this tip in Discord thanks to @fdncred; it's what I've been doing until this is resolved.

  11. dandavison commented on Dec 14, 2022

    @dandavison
    Contributor

    I have this problem at work also -- ssh -W used in .ssh/config and scripts that I don't want to alter. Here's a silly hack that seems to work (adds all single-letter flags to exec and passes them on): https://github.com/dandavison/nushell/pull/17/files

    That's obviously not the real solution. Maybe exec should be a special case in the parser?

  12. fdncred commented on Dec 22, 2022

    @fdncred
    Contributor

    closing as fixed by #7527. please re-open if it's not fixed.

  13. added this to the v0.74 milestone on Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:external-commands

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions