Ubuntu默认并没有安装ssh服务,如果通过ssh远程连接到Ubuntu,需要自己手动安装ssh-server。
判断是否安装ssh服务,可以通过如下命令进行:
ps -e|grep ssh
输出如下:
[email protected]:~$ ps -e|grep ssh
 2151 ?        00:00:00 ssh-agent

 5313 ?        00:00:00 sshd

ssh-agent表示ssh-client启动,sshd表示ssh-server启动了。

如果缺少sshd,说明ssh服务没有启动或者没有安装。
安装ssh-client命令:sudo apt-get install openssh-client

安装ssh-server命令:sudo apt-get install openssh-server

安装完成以后,先启动服务:sudo /etc/init.d/ssh start
启动后,可以通过“ps -e|grep ssh”查看是否正确启动。

ssh服务默认的端口是22,可以更改端口,使用如下命令打开ssh配置文件:
sudo gedit /etc/ssh/sshd_config

配置文件内容如下:

[plain] view plain copy
  1. # Package generated configuration file     
  2. # See the sshd(8) manpage for details     
  3. # What ports, IPs and protocols we listen for    
  4. Port 22  
  5. # Package generated configuration file  
  6. # See the sshd(8) manpage for details  
  7. # What ports, IPs and protocols we listen for  
修改端口号(Port)后,重启ssh服务即可生效,命令如下:
sudo /etc/init.d/ssh restart

ssh服务启动后,即可登陆,登陆命令格式为:ssh 帐号@IP地址
例如:ssh [email protected]
根据提示输入test的密码,即可远程登陆。

退出远程登陆命令:exit

演示如下图所示:

Ubuntu下ssh服务的安装与登陆(ssh远程登陆)

相关文章:

  • 2021-11-27
  • 2021-11-27
  • 2021-12-28
  • 2021-12-19
  • 2021-10-29
  • 2021-10-07
  • 2021-12-06
  • 2021-10-09
猜你喜欢
  • 2021-10-19
  • 2021-12-15
  • 2021-12-03
  • 2019-02-22
  • 2021-11-27
  • 2021-11-14
  • 2018-11-09
  • 2021-09-01
相关资源
相似解决方案