[LINUX] Ubuntu (18.04.3) SSH edition Key authentication

1. Update ``` $ ssh -p port number account [email protected] address ```

In the previous article, you can already enter from the Mac terminal.

$ sudo apt update

Every time. I will never forget this.

2. Creating a key (server side) As a key storage destination Create a key with /home/username/.ssh.
$ ssh-keygen -t rsa -f arbitrary name

Specify password.

Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 

Check below

$ ls

Any name: private key Any name.pub: Public key

3. Various settings (miscellaneous) ``` vi arbitrary name ``` This will copy the contents.

The rest is Mac /Users/username/.ssh/private key Copy the contents to and save.

Then do the following:

$cat arbitrary name.pub >> authorized_keys

Change permissions.

$ chmod 600 authorized_keys
$ chmod 700 /home/account name/.ssh

Delete original public key

rm -f arbitrary name.pub 

Delete private key

$rm any name

/etc/ssh/sshd_config Add (or uncomment) the following to.

+ChallengeResponseAuthentication no
+PubkeyAuthentication yes

sshd restart

$ sudo /etc/init.d/ssh restart

Create /Users/accountname/.ssh/config for Mac

Host account name
HostName IP address
User account name
        IdentityFile /Users/account name/.ssh/account name
Port Port number

with this,

$ssh account name

Put in

Password authentication is still possible at this point, so add (or uncomment) the following

+PasswordAuthentication no

Well then

$ssh account name
・ ・ ・ ・ ・ ・ ・ ・ ・

Oops ... It looks like you have to change the permissions on your Mac.

$ chmod 0600 ~/.ssh/

Then, once again.

Enter passphrase for key ‘・ ・ ・ ・ ・ ・

Now enter with the password you entered when creating the key.

By the way, it seems that the password for the ssh key cannot be saved with config.

Recommended Posts

Ubuntu (18.04.3) SSH edition Key authentication
Ubuntu (18.04.3) SSH edition
[SSH] About public key authentication and EC2
How to set up public key authentication in ssh
Stop SSH password authentication and switch to key authentication completely
Remove ssh private key passphrase
Set public key authentication when connecting with SSH in Teraterm
Ssh connection using public key
Use ssh with private key public key authentication. Connect from wan.
Log in to Raspberry PI with ssh without password (key authentication)
SSH public key authentication was set for Sakura VPS Cent OS 7.7
[Linux setting series] How to set public key authentication / ssh-keygen / ssh key / authorized_keys