一、开启ssh服务首先需要安装打开ssh服务的库:

sudo apt-get install openssh-server

二、检查当前的ssh开启情况:

ps -e |grep ssh

三、如果有sshd,则ssh-server已经启动;若仅有agent,则尚未启动;
开启ssh服务:

/etc/init.d/ssh start 或者systemctl restart sshd

四、如果希望开机自动启动ssh服务

sudo systemctl enable sshd

同样的,关闭服务命令为:

sudo systemctl disable ssh

单次开启服务

sudo systemctl start ssh

单次关闭服务

sudo systemctl stop ssh

针对自启动命令,输入之后reboot就可以,使用sudo systemctl status sshd命令查看ssh是否启动,看到Active: active (running)即表示成功
在这里插入图片描述

如果单纯开启ssh服务,那就ps查看ssh,再/etc/init.d/ssh start 或者systemctl restart sshd
在这里插入图片描述

连接xshell的时候一直连接不上, 重启之后也是不管用,这时候ifconfig查看虚拟机的网卡是否发生变化,因为ip非静态

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐