Create known hosts
On the local Linux computer e.g. a Raspberry Pi (local1) do the following:
- Open a Terminal.
- Type in the command.
$ ssh -oHostKeyAlgorithms='ssh-rsa' remote_user1@remote1
The prompt appears: Are you sure you want to continue connecting (yes/no)?
- Type in yes. Press RETURN.
- When prompted, type in the password for the remote1 computer's remote_user1.
The Terminal is now connected to the computer remote1 and remote_user1 is logged in.
The remote1 computer name is encrypted with the RSA encryption and stored in the Raspberry Pi's /home/local_user1/.ssh/known_hosts file.
- Type in exit.
The connection to remote1 is closed.
- If necessary, repeat the previous steps 2 to 4 for the IP address of the computer remote1.
$ ssh -oHostKeyAlgorithms='ssh-rsa' user1@192.168.8.101
Note: where 192.168.8.101 is the IP address for the computer remote1.
- On the local1 computer, open a Terminal.
- Type in the command:
$ ssh-keygen -t rsa
Enter file in which to save the key (/home/local_user1/.ssh/id_rsa):
- Press RETURN.
Enter passphrase (empty for no passphrase):
- Press RETURN.
Enter same passphrase again:
- Press RETURN.
The private key is generated in /home/local_user1/.ssh/id_rsa.
The public key is generated in /home/local_user1/.ssh/id_rsa.pub.
- On the computer local1, open a Terminal.
- Type in the command:
$ ssh-copy-id remote_user1@remote1
- When prompted, type in the password for remote_user1.
The public keys are installed on computer remote1.
The following steps should be executed on the remote computer remote1.
- Using a text editor, create a shell script file e.g. /opt/ros/melodic/env_remote1.sh with the following content.
#!/bin/bash export ROS_MASTER_URI=http://remote1:11311 source /opt/ros/melodic/setup.bash source /home/remote_user1/catkin_ws/devel/setup.bash exec "$@"
- Open a Terminal. Make the shell script executable.
$ sudo chmod a+x env_remote1.sh
Create and run local launch file
The following should be done on the local computer local1.
- Using a text editor, create a launch file e.g. run_remote.launch.
<launch> <machine name="remote1" address="remote1" env-loader="/opt/ros/melodic/env_remote1.sh" default="true" user="remote_user1" /> <node machine="remote1" pkg="beginner_tutorials" name="hello_doubles" type="hello_doubles" /> </launch>
Note: this launch file will run the hello_doubles node from the beginner_tutorials package on the remote1 computer.
- Open a Terminal. Type in the following command assuming the launch file is in the current directory:
$ roslaunch remote.launch
The following messages may appear. Ws06 in this example screenshot is the remote computer.