Linux 下开启ssh服务

要确认linux是不是安装了和开启了ssh服务可以输入 netstat -an|grep 22,查看22端口是否打开,如果找开,则证明SSH服务开启了。

 

1、修改sshd_config文件,命令为:vi /etc/ssh/sshd_config

 2、将#PasswordAuthentication no的注释去掉,并且将NO修改为YES

 3、将#PermitRootLogin yes的注释去掉

 4、验证SSH服务状态,命令为:/etc/init.d/sshd status

 5、重新启动SSH服务,命令为:/etc/init.d/sshd restart

这样子就能连接上了。

 

rpm -qa | grep ssh 可以看到系统中ssh安装包

rpm -ql openssh-3.5p1-6 查看该安装包安装信息(如安装路径,配置文件等)

ps -e | grep ssh 查看ssh服务有没有运行,如果有,可以看到类似以下内容:
2254 ? 00:00:00 sshd
这证明ssh已经在运行了,进程名为sshd
如果没有运行,可以通过以下命令运行之:
root]#/etc/rc.d/init.d/sshd start
root]#service sshd start
再看下这个ssh服务的网络连接情况: 
    root]#netstat -ntlp 
如果看到如下内容:
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      22109/sshd
这说明sshd已经能够正常工作了,如果利用客户端(SecurCRT,putty等)连接不上,尝试关闭防火
墙试试: service iptables stop
 
Ubuntu安装使用SSH
ubuntu默认并没有安装ssh服务,如果通过ssh链接ubuntu,需要自己手动安装ssh-server。判断是否安装ssh服务,可以通过如下命令进行:
ssh localhost   
ssh: connect to host localhost port 22: Connection refused   
ssh localhost
ssh: connect to host localhost port 22: Connection refused如上所示,表示没有还没有安装,可以通过apt安装,命令如下:
  sudo apt-get install openssh-server  
sudo apt-get install openssh-server系统将自动进行安装,安装完成以后,先启动服务:sudo /etc/init.d/ssh start   
sudo /etc/init.d/ssh start启动后,可以通过如下命令查看服务是否正确启动
ps -e|grep ssh   
6212 ?        00:00:00 sshd   
 6212 ?        00:00:00 sshd
如上表示启动ok。注意,ssh默认的端口是22,可以更改端口,更改后先stop,
然后start就可以了。改配置在/etc/ssh/sshd_config下,如下所示。
vi /etc/ssh/sshd_config   
# Package generated configuration file   
# See the sshd(8) manpage for details   
# What ports, IPs and protocols we listen for  
Port 22   
vi /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd(8) manpage for details
# What ports, IPs and protocols we listen for
Port 22
 
 
 
 

 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值