博客
关于我
亚马逊AWS实例设置为账号密码登陆
阅读量:464 次
发布时间:2019-03-06

本文共 739 字,大约阅读时间需要 2 分钟。

亚马逊AWS实例的登录方式

作为一个技术工作者,我个人对AWS实例的默认密钥登录方式感到不太习惯,毕竟需要记住一大串长得很不方便的密钥。于是,我尝试将其改为常规的账号密码登录方式,记录下整个过程。

1. 连接到实例

如果你使用的是XShell或者类似的终端工具,登录的时候记得选择centos用户,而不是root用户。虽然root用户权限很高,但实际操作中不太方便。连接时可能会遇到如下的提示:

WARNING! The remote SSH server rejected X11 forwarding request.Please login as the user "centos" rather than the user "root".

2. 设置密码登录

在改为密码登录之前,需要先为root用户设置密码。操作步骤如下:

  • 输入命令设置root用户密码:
  • sudo passwd root
    1. 切换到root用户:
    2. su root
      1. 输入以下命令启用用户名密码登录:
      2. sed -ri 's/^#?(PasswordAuthentication)s+(yes|no)/1 yes/' /etc/ssh/sshd_config
        sed -ri 's/^#?(PermitRootLogin)s+(yes|no)/1 yes/' /etc/ssh/sshd_config
        sed -ri 's/^/#/;s/sleep 10"s+/&n/' /root/.ssh/authorized_keys
        1. 重启SSH服务使其生效:
        2. service sshd restart

          这样设置之后,你就可以通过root账号使用密码登录到实例了。如果需要管理员权限,可以继续使用su root命令登录。

    转载地址:http://ozkbz.baihongyu.com/

    你可能感兴趣的文章
    npm ERR! ERESOLVE could not resolve报错
    查看>>
    npm ERR! fatal: unable to connect to github.com:
    查看>>
    npm ERR! Unexpected end of JSON input while parsing near '...on":"0.10.3","direc to'
    查看>>
    npm ERR! Unexpected end of JSON input while parsing near ‘...“:“^1.2.0“,“vue-html-‘ npm ERR! A comp
    查看>>
    npm error Missing script: “server“npm errornpm error Did you mean this?npm error npm run serve
    查看>>
    npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
    查看>>
    npm install CERT_HAS_EXPIRED解决方法
    查看>>
    npm install digital envelope routines::unsupported解决方法
    查看>>
    npm install 卡着不动的解决方法
    查看>>
    npm install 报错 EEXIST File exists 的解决方法
    查看>>
    npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
    查看>>
    npm install 报错 Failed to connect to github.com port 443 的解决方法
    查看>>
    npm install 报错 fatal: unable to connect to github.com 的解决方法
    查看>>
    npm install 报错 no such file or directory 的解决方法
    查看>>
    npm install 权限问题
    查看>>
    npm install报错,证书验证失败unable to get local issuer certificate
    查看>>
    npm install无法生成node_modules的解决方法
    查看>>
    npm install的--save和--save-dev使用说明
    查看>>
    npm node pm2相关问题
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>