sábado, 29 de enero de 2022

How to access local server without password


How to connected to a server  with ssh without password. This objective can be repetitive for to remember many password for each ssh access.

We will save time for access to easily. Also you can access to another co Worker without giving you the password.

When you want to remove the access to user. You don't need to change the login password of the server.
You only to have to remove the string key public from user that file is called authorized_keys.

Step 1: Create Your ssh key like client

You must be the next command: This generated your keys (a private key and a public key)
this files will be created into the folder: /home/user/.ssh/

Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:

Step 2: Add the public key in Server

The server should be have installed OpenSSH with this just open the 22 port that ssh use
sudo apt install openssh-server

Review and verified the available ports:

Now we using ssh-copy-id to connect to remote server and add the public key in the file /home/server/authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub pi@raspberrypi

pi@raspberrypi's password: ********
Now try logging into the machine, with "ssh 'username@remoteserver'", and check in:
to make sure we haven't added extra keys that you weren't expecting.

Well done. You can now access to server by SHH protocol without entering the password

ssh pi@raspberrypi

Reference: www.shellhacks.com

No hay comentarios.:

Publicar un comentario