"Error connecting to SSH server" when connecting to ROS in WSL2 using 'rosdevice' command in MATLAB
18 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2023-12-27
回答: MathWorks Support Team
2023-12-27
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,...
采纳的回答
MathWorks Support Team
2024-5-17
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Schedule Model Components 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!