The command ssh, or Secure Shell, is an encrypted protocol used to establish a secure connection to the command line interface of a remote machine. MacOS includes a built-in SSH client in the Terminal, allowing for quick and easy remote server access through a secure login.
>Synopsis
ssh [option] [user@IP-Address]
>Options
-p
If the remote server is using a non-standard port, you will need to specify this during the connection process.
Example:
-p
>ssh -p PORT_NUMBER USERNAME@IP_ADDRESS
The authenticity of host 'example.com (@IP-Address)' can't be established.
ECDSA key fingerprint is SHA256:d029f87e3d80f8fd9b1be67c7426b4cc1ff47b4a9d0a84.
Are you sure you want to continue connecting (yes/no)?
If you recently rebuilt your server, you might receive an error message when you try to connect. This happens when the remote host key changes. To fix this, revoke the key for that IP address. Accept the prompt by entering y or yes, which results in a one-time warning.
Example:
-R
>ssh-keygen -R @IP_ADDRESS
/Users/yourusername/.ssh/file updated.
Original contents retained as /Users/yourusername/.ssh/file.old
-v
Verbose mode is helpful in diagnosing SSH connectivity issues as it outputs all of the steps of the connection process.
Example:
-v
>ssh -v user@IP-Address
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Welcome to macOS 13.3 (Darwin Kernel Version 22.4.0)
Last login: Tue Nov 13 14:10:07 2024 from @IP-Address
user@hostname:~$
-i
If you wish to connect using an SSH key instead of a password, use this option.
Example:
-i
>ssh -i .file user@IP-Address
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-105-generic x86_64)
* Documentation: https://help.xxx.com
Last login: Tue Nov 13 13:45:07 2024 from @IP-Address
user@hostname:~$