GCP谷歌云AWS服务器开启SSH客户端root登录

说明:本脚也适用于其他云服务器(比如AWS)

GCP谷歌云为我们提供了几种登录云服务器的方式

不过大多数人还是喜欢拿到IP,拿出putty或者xshell

这样感觉更方便,比如我…

下面记录下怎么修改让它可以直接putty登录

首先点击连接后面的三角形,选择在浏览器中打开
GCP开SSH.PNG

然后一个新的浏览器窗口被开启,系统已自动登录,我们输入命令切换到root用户

sudo -i

输入命令编辑ssh配置文件

sudo vi /etc/ssh/sshd_config

找到下面两项内容,并修改(no改为yes,如果前面有#注释的去掉#)

PermitRootLogin yes
PasswordAuthentication yes

然后输入命令重启ssh

service sshd restart

如果没有设置过root密码就输入下面的命令设置root密码(会提示输入两次)

passwd root

发表评论 取消回复

2 条评论

  1. hen ni

    #!/bin/sh
    apt-get -y install wget vim
    echo root:54956705|chpasswd
    alias sur="su - root"
    alias vi="vim"
    cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup
    sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
    sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
    systemctl restart sshd
    wget -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/LocaleCN.sh && bash LocaleCN.sh
    wget --no-check-certificate -q -O bbr2.sh "https://github.com/yeyingorg/bbr2.sh/raw/master/bbr2.sh" && chmod +x bbr2.sh && bash bbr2.sh auto

  2. 2019

    谢谢