MENU

云主机开启SSH登录

2022 年 04 月 25 日 • 阅读: 579 • Index

密钥登录服务器执行以下命令:

sudo -i
passwd //设置密码
vi /etc/ssh/sshd_config
PermitRootLogin yes   //默认为no,需要开启root用户访问改为yes
PasswordAuthentication yes    //默认为no,改为yes开启密码登陆
vi .ssh/authorized_keys   //删除ssh-rsa之前所有内容
systemctl restart sshd

GCP:

sudo sh -c 'echo "root:密码" | chpasswd && sed -i "s/PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config && sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config && apt update && apt upgrade -y && service ssh restart'

以上命令仅在Ubuntu测试!

返回文章列表 文章二维码 打赏
本页链接的二维码
打赏二维码
歌曲封面
0:00