1. Open SSH
Mac terminal comes with SSH. You can use whereis to see it:
$ whereis ssh
However, the SSH process cannot be found in the existing process:
$ ps aux | grep sshapple 25927 0.0 0.0 2432784 616 s000 R+ 3:14下午 0:00.00 grep ssh
When you directly connect to a local host or remote host using SSH commands, the following error message is displayed:
ssh: connect to host localhost port 22: Connection refused
Google opened the remote logon because it was not enabled in the system settings. For details, see: How do I open port 22 in OSX 10.6.7.
Solution:
Open System preference settings-share and select remote Logon:
Enter SSH localhost for testing. If you are prompted to enter the password for authentication, it will be okay.
Now let's look at the grep process and we can see that the SSH process is running:
$ ps aux | grep sshapple 4656 0.0 0.0 2525056 1540 ?? S 三02下午 0:00.19 /usr/bin/ssh-agent -lapple 26009 0.0 0.0 2432784 612 s000 R+ 3:19下午 0:00.00 grep ssh
Ii. SSH and SCP
Next, you can use the SSH command to connect to other hosts, for example:
SSH [email protected]
Username is the username of the host to be logged on, and 192.168.100.100 is the IP address of the host to be logged on.
To view the number of logged-on users, run the who command.
The SCP command transfers files between the local host and the remote host. The simple usage is as follows:
$ scp .zshrc [email protected]:/Users/username/
This command copies the. zshrc file in the current path to the/users/username directory of the remote host.
This saves the trouble of resetting zshrc.
Reference: How to Use the CP and SCP commands in Linux
If the input [email protected] is incorrect, shell will not prompt any. Only by entering the correct address will we be asked to enter command authentication for the next step.
Remote Mac logon Using SSH