ssh以root用户登录ubuntu服务器

  • 更改root密码

    一般情况安装Ubuntu时,不会提示root用户的相关信息,自然无法知道root用户的密码.Ubuntu的root用户的密码是随机的,即每一次开机,都有一个新的root密码.我们在以其他用户进入系统后,可以使用sudo passwd 命令修改密码,输入新的密码后,此时的密码就是root用户的密码.之后再输入su root 就用这个密码就可以了.

  • 用ssh 以root用户登录服务器

    有了root用户的密码,还不能用ssh登录该服务器,因为ssh默认是阻止以root用户进行远程登录的.

    要使用root 用户登录,需要更改配置文件,做一下操作

    eric@ray:~
    $ ssh eric@192.168.122.xxx #以普通用户登录
    eric@192.168.122.xxx's password: 
    Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
      System information as of Thu Oct 25 08:09:04 UTC 2018
    
      System load:  0.0               Processes:           93
      Usage of /:   7.6% of 97.93GB   Users logged in:     0
      Memory usage: 9%                IP address for ens3: 192.168.122.190
      Swap usage:   0%
    
     * Security certifications for Ubuntu!
       We now have FIPS, STIG, CC and a CIS Benchmark.
    
       - http://bit.ly/Security_Certification
    
     * Want to make a highly secure kiosk, smart display or touchscreen?
       Here's a step-by-step tutorial for a rainy weekend, or a startup.
    
       - https://bit.ly/secure-kiosk
    
    
     * Canonical Livepatch is available for installation.
       - Reduce system reboots and improve kernel security. Activate at:
         https://ubuntu.com/livepatch
    
    28 packages can be updated.
    0 updates are security updates.
    
    
    Last login: Thu Oct 25 08:00:28 2018 from 192.168.122.1
    eric@oracle12c:~$ su root  #切换到root用户
    Password: 
    #修改配置文件
    root@oracle12c:/home/eric# vim /etc/ssh/sshd_config
    
    -----注释掉 PermitRootLogin without-password
    ------添加 PermitRootLogin yes
    
    #####重启服务
    root@oracle12c:/home/eric# /etc/init.d/ssh restart
    [ ok ] Restarting ssh (via systemctl): ssh.service.
    root@oracle12c:/home/eric# exit
    
    #退出后重新以root登录
    
    eric@ray:~
    $ ssh root@192.168.122.xxx
    root@192.168.122.xxx's password: 
    Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
      System information as of Thu Oct 25 08:13:38 UTC 2018
    
      System load:  0.0               Processes:           95
      Usage of /:   7.6% of 97.93GB   Users logged in:     0
      Memory usage: 9%                IP address for ens3: 192.168.122.190
      Swap usage:   0%
    
     * Security certifications for Ubuntu!
       We now have FIPS, STIG, CC and a CIS Benchmark.
    
       - http://bit.ly/Security_Certification
    
     * Want to make a highly secure kiosk, smart display or touchscreen?
       Here's a step-by-step tutorial for a rainy weekend, or a startup.
    
       - https://bit.ly/secure-kiosk
    
    
     * Canonical Livepatch is available for installation.
       - Reduce system reboots and improve kernel security. Activate at:
         https://ubuntu.com/livepatch
    
    28 packages can be updated.
    0 updates are security updates.
    
    
    
    The programs included with the Ubuntu system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.
    
    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
    applicable law.
    
    #登录成功
    root@oracle12c:~#
    
    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值