How to Execute Commands Remotely from Mac OS X using SSH

Sometimes you would need to login remotely on other remote machine to perform different tasks. For this purpose Mac OS x provides a client named OpenSSH. It is a secure client which provides you a safe and reliable connection between your MAC and the remote machine. It encrypts the connection over an insecure channel between the two unreliable hosts. Following guide will help you to learn using SSH on your MAC OS X.


  • 1

    Go to Utilities folder of your MAC, you can search utilities in spotlight search located on the top right corner of your MAC screen.

  • 2

    Click the applications folder and then click on the Terminal. It will launch your terminal application.

  • 3

    MAC OS X provides manuals for each command. To read any command's manual, type “man command” in your terminal without quotes. Do not forget to change command to your desired command for example in our case to read the manual of SSH command type “man SSH” without quotes. It will launch a page with a manual on SSH. Once you are done with reading, close the page.

  • 4

    Now go to terminal and type without quotes “ssh username@hostaname”.  You have to substitute the username field to the actual username on the remote machine and for the hostname field you can provide hostname of the remote machine and can also its IP address. Once you are done with it, hit enter.

  • 5

    The default port for remote administrator is 22 but sometimes remote administrators reconfigure the port. So in case you get an error stating “connection refused because port 22 is not accepting connection”, contact the administrator on the remote machine to get the port number and then append –pXXX option after SSH, where XXX will be substituted by the port number of the remote machine.

    If you get an error stating “could not resolve hostname” then recheck the hostname or IP then repeat the above steps.

  • 6

    Now terminal will ask you to enter the password for the username you provided. Type the password and hit enter. Once the password is verified, connection will be established between your MAC and remote host and you will be able to execute commands remotely.

Leave a Reply

Your email address will not be published. Required fields are marked *

+ three = 4