ceturtdiena, 2018. gada 25. janvāris

How to connect to remote linux machine with key without entering password


On workstation

Create public/private key pair.
Put private key in  .ssh/id_rsa. Assign permissions as below.
ssh-keygen -t rsa -b 4096
mkdir .ssh
mv yolo ../.ssh/id_rsa
cd ../.ssh
chmod 600 id_rsa
cd ../
chmod 700 .ssh

On server

You need to create directory .ssh on substitute
Creat file authorized_keys
Assign appropriate permissions on file and directory
chmod 700 .ssh
cd .ssh
nano authorized_keys
chmod 600 authorized_keys
Connection made in form ssh username@hostname

How to avoid prompting password for sudo

In file /etc/sudoers modify add row where 'username' are your username
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
username ALL=(ALL) NOPASSWD:ALL
One key can be used to connect to any number of hosts.

Nav komentāru:

Ierakstīt komentāru