虚拟机中要安装好sshd服务:
sudo apt-get install openssh-server
一般来说,安装完成后就可以了,不需要再额外做配置,下次虚拟机启动sshd服务也会启动。
确认sshd服务是否启动可以如下:
abc@abc-VM:~$ ps -e | grep sshd
519 ? 00:00:00 sshd
913 ? 00:00:00 sshd
989 ? 00:00:00 sshd
有类似上面的输出就说明sshd已经启动了。
在windows的cmd窗口执行:
> ssh abc@abc-VM
abc@abc-vm's password:
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-22-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch
0 packages can be updated.
0 updates are security updates.
Last login: Sat Jun 9 10:08:30 2018 from 192.168.1.187
abc@abc-VM:~$ date
2018年 06月 09日 星期六 10:17:21 CST
ssh登录成功,这样就不用再打开个Hyper-V的虚拟机窗口了。