Re: User name prompt with ssh

From: Greg Wooledge (wooledg_at_eeg.ccf.org)
Date: 09/02/05

  • Next message: OpenMacNews: "help? ssh connect w/ DSA pubkey auth keeps asking for passphrase; w/ RSA pubkey auth, all is OK"
    Date: Fri, 2 Sep 2005 14:00:58 -0400
    To: Johan De Meersman <jdm@operamail.com>
    
    

    On Fri, Sep 02, 2005 at 10:54:20AM +0200, Johan De Meersman wrote:
    >
    > ---begin prompt-ssh.sh---
    > #!/bin/bash
    > read -p "Please enter your remote username: " SSH_LOGIN
    > real-ssh -l "$SSH_LOGIN" $*
    > ---end prompt-ssh.sh---

    You'll want "$@" (with the quotes) on the end of the last line, not $*. Or
    if you use #!/bin/sh instead of bash, you'll want ${1+"$@"} for historical
    reasons.

    Otherwise, you'll get the wrong results when users pass quoted strings with
    spaces in them as arguments to ssh.

    "$@" is equivalent to "$1" "$2" "$3"... for however many arguments there are.
    "$*" is equivalent to "$1 $2 $3..."
    $* or $@ (unquoted) is equivalent to $1 $2 $3...


  • Next message: OpenMacNews: "help? ssh connect w/ DSA pubkey auth keeps asking for passphrase; w/ RSA pubkey auth, all is OK"

    Relevant Pages