SSH login, are you still entering your password? You can omit it by using the public key authentication method!
The environment is
Client side: Linux (including WSL / 2 environment) Server side: Linux
Is assumed.
Below, work on the client side quickly.
You'll be asked a lot, but all you can do is enter.
$ ssh-keygen -t ed25519
Register the public key generated above in the server you want to log in to.
$ cat ~/.ssh/id_ed25519.pub | ssh <User name>@<host> 'cat >> ~/.ssh/authorized_keys'
$ ssh <User name>@<host>
You can log in without a password! Yatter!
It wasn't swaying, but it wouldn't be quick if the server wasn't ready. If it doesn't work, check the following on the server side of the connection destination.
Make sure the permissions on the .ssh
directory and the ʻauthorized_keys` file are correct.
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
Open the sshd configuration file.
$ sudo vim /etc/ssh/sshd_config
If PubkeyAuthentication
is commented out or no
, the public key authentication method is disabled, so set it with yes
as follows.
PubkeyAuthentication yes
Restart the sshd service to reflect
$ sudo systemctl restart sshd
RSA
There is no reason to make a positive choice in terms of security and speed. As for security, it seems that 4096bit is still okay. If not specified, it will be generated in 2048bit.
$ ssh-keygen -t rsa 4096
ECDSA
It uses a more secure and faster signing algorithm than RSA. The key length is 256, 368, 521 bits. 521 is correct instead of 512. Even 521bit is faster than RSA and is a safe choice now.
$ ssh-keygen -t ecdsa -b 521
Ed25519
Since it is new, you may come across an SSH server that does not support it. It uses a more secure and faster signing algorithm than ECDSA. The key length is fixed at 256 bits.
$ ssh-keygen -t ed25519