566 tutoriels disponibles
Chercher un tutoriel
Bienvenue
sur Shareannonce
 
Create ssh-keygen between 2 computers
Ecrit par: Shareannonce
Date création:  24-02-2019
Nombre de vues:  1808
Catégorie:  informatique > developpement > linux
Note: 
 
   Tutoriel N° 2ce

Create ssh-keygen between 2 computers


First of all, you need activate port redirection on your router for TCP, USD port 22!
(or another port used for ssh)

Machine 1:
IP address: IP_machine_1
login/pass: login1/pass1

Machine 2:
IP address: IP_machine_2
login/pass: login2/pass2

-------------------------------------------------------------------------------------------------------------------------------------

install openssh-server on Machine1 and Machine2

sudo apt update
sudo apt-get install openssh-server

#if you need root user
sudo nano /etc/ssh/sshd_config

PermitRootLogin yes


sudo service ssh restart

-------------------------------------------------------------------------------------------------------------------------------------

On machine 1:
Access to the machine 2 since the machine 1

ssh-keygen -t rsa -b 2048
ssh-copy-id -i ~/.ssh/id_rsa.pub login2:pass2@IP_machine_2

ssh login2:pass2@IP_machine_2

SSH connection without password on machine 2:

ssh login2@IP_machine_2

Copy file toto.txt withtout password on machine2:

scp toto.txt login2@IP_machine_2:/path_machine2
scp -r folder login2@IP_machine_2:/path_machine2

Execute a remote script since machine1 on machine2

ssh login2@IP_machine_2 'sh /path_machine2/script.sh'

-------------------------------------------------------------------------------------------------------------------------------------

On machine 2:
Access to the machine 1 since the machine 2

ssh-keygen -t rsa -b 2048
ssh-copy-id -i ~/.ssh/id_rsa.pub login1:pass1@IP_machine_1

SSH connection without password on machine 1:

ssh login1@IP_machine_1

Copy file toto.txt withtout password on machine1:

scp toto.txt login1@IP_machine_1:/path_machine1
scp -r folder login1@IP_machine_1:/path_machine1

Execute a remote script since machine2 on machine1

ssh login1@IP_machine_1 'sh /path_machine1/script.sh'

-------------------------------------------------------------------------------------------------------------------------------------

Note: if you have a few users on the same machine:

You should not create a few ssh-keygen
You need only push the key: ssh-copy-id -i ~/.ssh/id_rsa.pub login:pass@IP_machine


 
 
   Autres tutoriels de la même catégorie >
 
ShareAnnonce version 2.0 Tous droits reserves. | Condition d'utilisation | Contact