I am trying to create a simple alias for SSH-ing to a host, like the below:

alias wpessh='ssh $1@$1.ssh.wpengine.net'

I also tried using a function as suggested by other answers here:

function wpessh { ssh "$1"@"$1".ssh.wpengine.net; }
export -f wpessh

But neither has worked.


wpessh mysite

Expected Output (expected command to be run)

ssh mysite@mysite.ssh.wpengine.net
  • What shell are you using? What happens if you add an echo for debugging purposes, i.e. function wpessh { echo ssh "$1"@"$1".ssh.wpengine.net; } – Sparhawk Oct 29 '18 at 9:44
  • @Sparhawk I'm just using OSX terminal. If I echo the function as you describe, I receive the SSH usage:[....] – wickywills Oct 29 '18 at 9:59
  • What's the $1 contents when issuing the alias? What's the resulting command (try set -x)? Why the upper case SSH in the error msgs? – RudiC Oct 29 '18 at 10:02
  • check this out unix.stackexchange.com/questions/3773/… it may be helpful – BlackCrystal Oct 29 '18 at 10:05
  • 1
    @wickywills I executed the function wpessh { echo ssh "$1"@"$1".ssh.wpengine.net; } in my OSX Shell both in bash and zsh and it's working fine. – BarathVutukuri Oct 29 '18 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.