Borrar filtros
Borrar filtros

"Error connecting to SSH server" when connecting to ROS in WSL2 using 'rosdevice' command in MATLAB

18 visualizaciones (últimos 30 días)
I just installed Windows Subsystem for Linux (WSL2) and MATLAB R2021b including ROS Toolbox.
Now I'm trying to connect to WSL2 by 'rosdevice' command, but it failed with errors.
How can avoid the errors?
Code:
>> username = 'USER';
>> password = 'PASSWORD';
>> wsl2_ip_addr = 'IP ADDRESS';
>> d = rosdevice(wsl2_ip_addr,username,password);
Error:
Error using ros.codertarget.internal.ssh2client (line 72)
Error connecting to SSH server at <IP ADDRESS>
Error in ros.codertarget.internal.RemoteLnxSystemExecutor (line 20)
      obj.Ssh = ros.codertarget.internal.ssh2client(deviceAddress,varargin{:});
Error in ros.codertarget.internal.createSystemExecutor (line 10)
  systemExecutor = ros.codertarget.internal.RemoteLnxSystemExecutor(deviceAddress,varargin{:});
Error in rosdevice (line 122)
      obj.SystemExecutor = createSystemExecutor(obj.DeviceAddress,...

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 17 de Mayo de 2024
The error message says that MATLAB couldn't establish SSH connection to the WSL2 environment.
There are two things you should check.
1) SSH server status in WSL2
Make sure ssh service is running when trying to run "rosdevice", you can validate this by typing:
$ service ssh status
on WSL2 terminal.
If it shows "* sshd is running", move on to next step.
If not, get ssh service active on WSL2 before moving forward, following instruction like this link.
2) Log in information
Type the following command on WSL2 terminal to find the correct IP address under "eth0->inet", note that this address may varies next time when you reopen WSL2:
$ ifconfig
Note:
In some cases, WSL2 hasn't installed 'net-tools' package which includes 'ifconfig' command, and you have to install it manually by 'apt-get' command.
But, default configuration of WSL2 is sometimes not sufficient to do name resolution, namely, using 'apt-get' command.
In such case, you should configure nameserver in /etc/resolv.conf like this link:
nameserver 8.8.8.8
Also, you should disable auto regeneration of resolv.conf by adding the below lines into /etc/wsl.conf.
[network]
generateResolvConf = false
Disabling VPN client software is also a possible workaround, because it sometimes blocks the SSH connection.
Other SSH client like Git Bash will be useful to verify whether SSH settings and log in information are correct or not.

Más respuestas (0)

Categorías

Más información sobre Schedule Model Components en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by