美文网首页
ubuntu 新系统初始化

ubuntu 新系统初始化

作者: 符精华 | 来源:发表于2022-05-09 15:06 被阅读0次

    cp -r/etc/apt/sources.list/etc/apt/sources.list.bak

    sed -i's#http://deb.debian.org#https://mirrors.aliyun.com#g' /etc/apt/sources.list

    sudo apt update

    sudo apt install openssh-server

    sudo systemctl status ssh

    /etc/init.d/ssh start

    sudo echo " PermitRootLogin yes "  >>  /etc/ssh/sshd_config

    sudo ufw allow ssh

    sudo systemctl disable --now

    sudo systemctl enable --now ssh

    cat ~/home/id_rsa.pub >> ~/.ssh/authorized_keys

    ### 更新软件包索引

    sudo apt update

    ### 安装 ssh 服务

    sudo apt install openssh-server

    ### 查看 ssh 状态

    sudo systemctl status ssh

    - 如果运行状态不为active(running),需要手动开启,命令为:

    /etc/init.d/ssh start

    ### 修改 ssh 配置

    sudo vim /etc/ssh/sshd_config

    # 将PermitRootLogin prohibit-password那一行修改为PermitRootLogin yes

    # 去掉前面的#号将port 22前面的#去掉

    ### 检查防火墙

    sudo ufw allow ssh

    ### 重新注册ssh服务并附带立马启动

    sudo systemctl disable --now ssh

    sudo systemctl enable --now ssh

    ### ssh免密登录设置方法

    cat ~/home/id_rsa.pub >> ~/.ssh/authorized_keys

    相关文章

      网友评论

          本文标题:ubuntu 新系统初始化

          本文链接:https://www.haomeiwen.com/subject/ebuhurtx.html