ubuntu开启sshd

  1. SSH分客户端openssh-client和openssh-server

如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-get install openssh-client),如果要使本机开放SSH服务就需要安装openssh-server。

  1. 查看当前的ubuntu是否安装了ssh-server服务。默认只安装ssh-client服务。
    dpkg -l | grep ssh

  2. 安装ssh-server服务
    sudo apt-get install openssh-server

再次查看安装的服务:
dpkg -l | grep ssh

然后确认ssh-server是否启动了:
ps -e | grep ssh

如果看到sshd那说明ssh-server已经启动了。

如果没有则可以这样启动:sudo /etc/init.d/ssh start或sudo service ssh start

配置相关:

ssh-server配置文件位于/etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。(或把配置文件中的”PermitRootLogin without-password”加一个”#”号,把它注释掉,再增加一句”PermitRootLogin yes”)

然后重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start

安装ufw

ufw是用来开启22端口的,因为ssh服务需要用到22端口
在终端输入sudo apt-get install ufw
启用ufw:sudo ufw enable
开启22端口:sudo ufw allow 22

安装netstat

netstats是用来查看机器网络状况的
在终端输入sudo apt-get install netstat
输入管理员密码完成安装

查看22端口是否打开

在终端输入netstat -ntlp | grep 22
posted @   哈喽哈喽111111  阅读(653)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2019-09-20 mysql+canal+kafka+elasticsearch构建数据查询平台
2019-09-20 zookeeper集群搭建
2019-09-20 另类--kafka集群中jmx端口设置
2019-09-20 kafka集群中jmx端口设置
2019-09-20 使用zookeeper报错 stat is not executed because it is not in the whitelist. envi is not executed because it is not in the whitelist.
点击右上角即可分享
微信分享提示