Ecrit par: Shareannonce
Date création:  24-02-2019
Nombre de vues:  340
Catégorie:  linux
Note: 
Tutoriel N° 2ce - Create ssh-keygen between 2 computers : informatique > developpement > linux

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 fiches (news, tutoriaux ou petites annonces) de David de la même catégorie >
Install dart on UBuntu
Ecrit par Shareannonce
Sha256sum OK
Ecrit par Shareannonce
Htaccess htpasswd
Ecrit par Shareannonce
Settings speed scroll magicmouse for ubuntu
Ecrit par Shareannonce
Associate same bluetooth mouse on macos and linux
Ecrit par Shareannonce
Installing ubuntu on a bootable usb stick on mac
Ecrit par Shareannonce
Https://www.mail-tester.com
Ecrit par Shareannonce
La commande flush ne fonctionne pas par defaut
Ecrit par Shareannonce
Avec linux ou osx lire ligne spf de la zone
Ecrit par Shareannonce
Mercanet, etransaction socgen ...
Ecrit par Shareannonce
 
ShareAnnonce version 1.0 Tous droits reserves. | Condition d'utilisation | Qui sommes nous ? | Contact