where ipaddress is the ip address of the computer to be remotely access and the username is a authorized user on that computer. If you received the following error:
ssh: connect to host ipaddress port 22: Connection refused
The error is caused by the target computer does not have updated openssh server.
For Ubuntu, to rectify the problem, login to the target computer and launch the terminal. Then type the following commands:
$sudo apt-get install openssh-client openssh-server
For MacOS, go to Finder, and launch the "System Preferences...", click the "Sharing", check "File Sharing"and "Remote login". And in the "Remote Login", set "Allow access for " to "All Users"