«

»

OS X bash profile alias configuration

Based on my blog post sshpass configuration & usage i have received a few questions about what configuration i have on the laptop i use for my daily work. The most obvious differences between the sshpass blog post and this one is that i’m:

  • Using a MacBook, OS X El Capitan version 10.11.6, and not a Linux based laptop.
    • The bash_profile configuration has also been tested on OS X Sierra
  • Not using sshpass on my MacBook

However i got a few aliases defined in the .bash_profile file which you can find in the user home directory on your MacBook. My bash_profile includes the following:


Click the picture or scroll down to the bottom of the blog post to see the file content. Yes it’s a fake IP address specified for the HQ jump workstation:)

The included aliases are:

  • mssh – which will start a ssh session to a specific target by just typing “mssh” at the terminal.
  • rssh – which will start a ssh session to the target specified while running the alias. The root user account will be used. Type “rssh FQDN/IP-address” to start a session
  • nssh – which will start a ssh session to the target specified while running the alias. The nutanix user account will be used. Type “nssh FQDN/IP-address” to start a session.

Follow the below procedure to manage your aliases:

  • Open a Terminal, i’m using iTerm
    screen-shot-2016-12-29-at-10-22-01
  • Start editor (vi in my case but you can use nano or other editor of your choice). If no .bash_profile file exists it will be created when you exit the editor
    screen-shot-2016-12-29-at-10-22-52
  • Make your changes, save and exit. To save and exit a file using vi, press the following four charachters
    • :wq!
  • start a new Terminal window or source the new .bash_profile into the existing terminal window by running:
    • source .bash_profile
      screen-shot-2016-12-29-at-10-25-44

Now lets try the alias which will setup a ssh session to my HQ jump workstation by just typing “mssh”


.bash_profile file:

# Terminal setting
TERM=xterm
# SSH alias
alias ssh='ssh -o ServerAliveInterval=15 -o CheckHostIp=no  -o TCPKeepAlive=yes -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
# Alias for connecting to HQ jump workstation
alias vcdx56='ssh nutanix@10.10.100.111'
# Alias for connecting to remote hosts using SSH and the root user account
alias rssh='/usr/bin/ssh -o ServerAliveInterval=15 -o CheckHostIp=no  -o TCPKeepAlive=yes -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1 -l root'
# Alias for connecting to Nutanix CVMs using SSH and the Nutanix user account
alias nssh='/usr/bin/ssh -o ServerAliveInterval=15 -o CheckHostIp=no  -o TCPKeepAlive=yes -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1 -l nutanix'