1、 Turn on the key login mode on the server side
/etc/ssh/sshd_config
# Whether to allow root Remote login
PermitRootLogin yes
# Whether password login is turned on
PasswordAuthentication yes
# Turn on public key authentication
RSAAuthentication yes # This parameter may not No problem
PubkeyAuthentication yes
# The file location where the login user's public key is stored
# The location is under the home directory of the login user name .ssh
# root Namely /root/.ssh
# foo Namely /home/foo/.ssh
AuthorizedKeysFile .ssh/authorized_keysauthorized_keys It's a document , It's not a folder
# restart , Make the configuration work
service sshd restart2、 The client creates its own secret key pair
ssh-keygen -t rsa
# If appear , Already exists , Situations that need to be covered , Name alias required , To avoid overwriting other configurations
cd ~/.ssh/
# View public key
cat id_rsa.pub
# Configure login alias Save losing ip trouble
# .ssh/config
vi config
Host workhost0 # Login server alias ssh examp That's all right.
HostName 8.140.130.30 # The server to log in to ip
Port 22
User root # Login name
IdentityFile ~/.ssh/id_rsa # Your private key path
ServerAliveInterval 30
TCPKeepAlive yes
# You can configure multiple , To support multiple password free logins 3、 Add your public key to the server-side public key certificate
Copy the public key in the file to the remote host ~/.ssh/authorized_keys in , If you don't have this file , So please create a new .
authorized_keys It's a document , It's not a folder
4、 The client can log in without secret
ssh workhost0### Small Tips
1、~ It's in the current user directory ,Linux Is in root Under the document ( Not in the outermost directory )
2、 use VScode Open remote and local file directories , It can be omitted. Vim The cost of operating documents
Reference link
1、Mac Terminal configuration ssh Secret free login tutorial
https://blog.csdn.net/weixin_...








