A note on ssh connection from macOS Catalina to CentOS7.7. Obviously, it can be used not only on macOS but also on linux and * BSD environments.
Shell command
mkdir -m 0700 ~/.ssh
ssh-keygen
The passphrase is enter key only. Then, the private key (id_rsa) and public key (id_rsa.pub) are generated in the .ssh directory under the home directory.
~/.ssh ┣ id_rsa ┗ id_rsa.pub
Copy the public key to the server.
Shell command
cd ~/.ssh
scp id_rsa.pub (Username on the server)@Server IP:.
Log in to the server once with ssh.
Shell command
ssh (Username on the server)@Server IP
Register the public key.
Shell command
mkdir -m 0700 ~/.ssh
cd ~/.ssh
cat ~/id_rsa.pub >> authorized_keys
chmod 0600 authorized_keys
Set up public key authentication on the server.
Shell command
vi /etc/ssh/sshd_config
Modify as follows. #PubkeyAuthentication yes ▼ PubkeyAuthentication yes
Restart sshd.
Shell command
service sshd restart
Now you can ssh login from the client side to the server without password authentication.
that's all.
Recommended Posts