Make a key with PuTTygen on the client side. If you don't have PuTTygen, please install PuTTy.
Format the public key you sent into a format that can be used by the server.
$ ssh-keygen -i -f key name.pub >> authorized_keys
Create a .ssh directory in / home / user name.
$ mkdir /home/user name/.ssh
Move the formatted public key to .ssh.
$ mv authorized_keys /home/user name/.ssh
Set access privileges for authorized_keys.
$ chmod 600 .ssh/authorized_keys
Set access rights for .ssh.
$ chmod 700 .ssh
With the above settings, you can now ssh connect using the key authentication method. From here, for added security, change the server settings to prevent password authentication and change the port.
Open the ssh configuration file in an editor.
$sudo vim /etc/ssh/sshd_config
Disable password authentication.
Change the port number in sshd_config.
$service sshd restart
This completes the settings. When connecting from wan, use the port forwarding function of the router.
Log in from the client using the private key from PuTTy. For the private key, specify the path from the Auth field in the SSH of Category: Connection.
I didn't realize I had to format my public key on linux and took a long time to set it up.