Just contact with the Mac soon, in the use of some of their own small problems, now one record down for others to reference and learn from their own.
SSH command: SSH (-p port) User name @ Remote server IP.
To implement SSH login server, the first thing to ensure that the Mac and server SSH service is open, and their related commands are as follows:
Linux:service sshd Start (start: Turn on stop: Close restart: Restart Status: View service status; Know what to ignore)
Mac:1. Edit the/etc/sshd_config file, comment out
#ForceCommand/usr/local/bin/ssh_session
2. Start the SSHD service:
sudo launchctl load-w/system/library/launchdaemons/ssh.plist
3. Stop the SSHD service:
sudo launchctl unload-w/system/library/launchdaemons/ssh.plist
4 to see if it starts:
sudo launchctl list | grep ssh
The second is to generate the key:
Execute the command under Terminal:
SSH-KEYGEN-T RSA
All the way to enter, the various prompts by default do not change, wait for the completion of execution. Then execute:
LS ~/.ssh
#可以看到两个密钥文件: Id_rsa (private key) id_rsa.pub (public key)
Finally, put the key on the server:
Place the public key to the Linux server. To use the SCP command:
SCP ~/.ssh/id_rsa.pub User name @ server ip:/home/cssor/.ssh/
Then add the id_rsa.pub content to the server side of the default authentication file Authorized_keys, execute:
#先登录到远程服务器
CD ~/.ssh
Cat-n/home/cssor/.ssh/id_rsa.pub >> Authorized_keys #将公钥内容加入到authorized_keys文件, no, just create one.
Precautions:
The public key should be placed in the home directory of the account used by the login server, such as when you log in to the remote server with ABC, the public key will be placed under/home/abc/.ssh/, Authorized_keys file is also in this directory.
Here's the problem I'm having:
The 1.mac SSH service is not sure whether it is turned on.
2. The remote server after login, the user name automatically converted to the root account, this situation to special attention, this time, the public key can not be placed in their home directory, to put Authorized_keys into the remote server root account directory/root/.ssh/; In the client login to use the root account, the command is as follows: SSH [email protected] Server IP.
Mac ssh password-free login server