How do I SSH on a Mac with Terminal? – ServerMania
ssh or secure shell is an encrypted connection protocol used to connect to the command line interface of a remote machine. mac os has a built-in ssh client called a terminal that allows you to quickly and easily connect to a server.
In this article, we will describe how to connect to a server using the terminal program in OS X Mac.
how ssh works
ssh uses tcp port 22 by default, although this can be changed to a non-standard port. the ssh process uses symmetric encryption, asymmetric encryption, and hashing to securely connect the client to the remote server.
The first time you connect to the server, you will be prompted to verify the server’s public key. on future connections, the client will reference this verified public key to ensure that it is still connecting to the same server by referencing the unknown_hosts file.
both client and server negotiate a session key that is used to encrypt and decrypt data sent during the ssh connection.
finally, the server authenticates the client using an ssh key (if available and used).
see also: (live webinar) meet servermania: transform your server hosting experience
what you will need
- a server accessible via ssh on a public ip address
- the ip address of the remote server
- the username and password of a user on the server
- a mac os computer
connect to a server via ssh in the terminal
step 1: open terminal
In Finder, open the Applications folder and double-click the Utilities folder.
double-click the terminal application. you can drag this icon to your dock for easy access.
Step 2: Enter the standard ssh command
The basic syntax to connect to ssh is as follows:
ssh [protected email]
replace username and ip address with the username and ip on the remote server. press return to execute the command.
This will connect to the server via ssh with the username user and the default ssh port 22. The connection will look similar to the following:
ssh command examples and options
here are some examples of common ssh commands that can be used in the terminal application.
getting a list of ssh commands and syntax
ssh
specify a port in ssh
if the remote server uses a non-standard port, you will need to specify it during the connection process:
ssh -p 24601 [protected email]
connecting with an ssh key
If you want to connect using an ssh key instead of a password, use the following command:
ssh -i key.file [protected email]
connecting in verbose mode
verbose mode is useful for diagnosing ssh connectivity problems, as it shows all the steps of the connection process:
ssh -v [protected email]
terminate ssh connection
Type exit to end the connection.
mac os terminal customization
the default terminal on mac is a gray and white interface like this:
but there are a variety of different color settings, including dark mode. you can change the look of the terminal in terminal > preferences menu:
double-click a new theme in the profiles tab to open a new terminal window. click the default button to set the new theme as the default.
Your new terminal theme is now active.
next steps
Now that you’re connected to the remote server, you can run any commands available in that particular environment. To make things easier during future sessions, you can set up an ssh key pair so that you don’t need to enter a password when connecting via ssh in the terminal.
need help connecting to your servermania server via ssh in terminal? Please contact our support team or share your feedback in the comments below.