• 023.Ubuntu常见个性化配置


    root登录设置

    ubuntu默认关闭了root账户,可根据实际情况开启或关闭root登录。

    ubuntu@localhost:~$ sudo apt install openssh-server
    ubuntu@localhost:~$ sudo passwd root
    New password: 【输入密码】
    Retype new password:【输入密码】
    ubuntu@localhost:~$ sudo vim /etc/ssh/sshd_config
    ……
    Port 2345                                           #修改SSH端口默认端口
    ……
    PermitRootLogin yes                                 #允许root用户登录
    #PermitRootLogin no                                 #禁止root用户登录
    PasswordAuthentication yes                          #允许密码登录
    #PasswordAuthentication no                          #禁止密码登录,如使用公钥登录
    ……
    ubuntu@localhost:~$ sudo systemctl restart sshd     #重启sshd服务
    [root@client ~]# ssh -p 2345 root@172.24.8.111      #客户端测试服务端连接
    root@172.24.8.111's password:【输入密码】
    

    修改DNS

    建议修改dns为国内主流dns服务商地址,如阿里云dns。

    root@localhost:~# vi /etc/netplan/50-cloud-init.yaml
    network:
        ethernets:
            eth0:
                addresses:
                - 172.24.8.111/24
                dhcp4: false
                gateway4: 172.24.8.2
                nameservers:
                    addresses:
                    - 223.5.5.5                 #DNS修改为阿里云公共dns
                    search: []
        version: 2
    

    修改apt源

    建议修改apt源为国内主流apt提供商地址,如阿里云apt源。

    root@localhost:~# sudo vim /etc/apt/sources.list
    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    

    更多参考:https://developer.aliyun.com/mirror/ubuntu

    更新系统

    root@localhost:~# apt-get update && apt-get upgrade -y && apt-get autoremove -y
    

    安装常用服务器软件

    root@localhost:~# sudo apt-get -y install net-tools vim wget ntp bash-completion build-essential gcc openssh-client lvm2 make terminator git ssh lrzsz htop
    

    以上主要为一些服务器相关软件,可根据实际情况安装必要组件。

    修改语言环境

    root@localhost:~# sudo vi /etc/default/locale
    LANG="zh_CN.UTF-8"
    LANGUAGE="zh_CN:zh"                 #设置为中文
    
    LANG="en_US.UTF-8"  
    LANGUAGE="en_US:en"                 #需要为英文
    

    创建新用户及免密钥配置

    创建用户

    root@localhost:~# adduser xianghy   #填写相关信息创建用户
    

    登录测试

    [root@client ~]# ssh xianghy@172.24.8.111       #客户端测试登录
    xianghy@172.24.8.111's password: 【输入密码】
    

    免密钥登录

    [root@client ~]# ssh-keygen -f ~/.ssh/xianghy_key -N ''                         #客户端创建私钥
    [root@client ~]# ssh-copy-id -i ~/.ssh/xianghy_key.pub xianghy@172.24.8.111     #上传公钥至服务端
    

    客户端配置登录别名

    [root@client ~]# vim ~/.ssh/config
    Host xianghyhost                    #主机别名
        HostName 172.24.8.111           #服务端IP
        Port 2345                       #服务端SSH端口
        User xianghy                    #服务端用户名
        IdentityFile ~/.ssh/xianghy_key #私钥文件路径
    [root@client ~]# chmod 600 ~/.ssh/config
    

    免密钥登录测试

    [root@client ~]# ssh xianghyhost                                            #使用别名登录测试
    [root@client ~]# ssh -p 2345 xianghy@172.24.8.111 -i ~/.ssh/xianghy_key     #使用命令行参数登录测试
    

    关闭防火墙

    root@localhost:~# systemctl stop ufw.service
    root@localhost:~# systemctl disable ufw.service
    

    时钟服务器配置

    chrony服务配置

    参考:《001.Chrony时间服务器

  • 相关阅读:
    .NET平台下Web树形结构程序设计李洪根
    [总结]Asp.net中的页面乱码的问题
    [原创]Datagrid中绑定DropDownList的例子
    [原创]TreeView的递归问题!FAQ
    [个人]我所有的Email地址!
    心情随笔(一)
    [原创]用JS做的一个打字程序(为网友qixiao)
    [转贴]一个通用的数据分页的存储过程
    [转贴]怎么样写一个XML文件到客户端
    [原创]用JS给DropDownList添加新项!
  • 原文地址:https://www.cnblogs.com/itzgr/p/13709375.html
Copyright © 2020-2023  润新知