ubuntu初始配置
记录装机后关于网络,root用户的使用,修改源,ssh免密登录,时区设置,docker安装等多个配置。(方便以后使用,免得到网上找多个教程还不适用)
- server版本默认安装了vim,桌面版可以使用gedit做编辑器。也可以之后安装vim
apt-get install -y vim
配置以太口:
先用命令ifconfig
查到网卡
再根据实际网络修改/etc/network/interfaces
下配置
然后重启网卡:/etc/init.d/networking restart
修改源
sudo vi /etc/apt/sources.list
为阿里或者其他国内的
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
user-session=ubuntu
greeter-show-manual-login=true
all-guest=false
apt-get install -y openssh-server
配置ssh可以使用root用户
/etc/ssh/sshd_config
下找到PermitRootLogin
一行。
改为:PermitRootLogin yes
ssh免密登录服务器note2
两台服务器都先生成自己的秘钥:ssh-keygen -t rsa -P ''
将note1的公钥复制到note2中:scp ~/.ssh/id_rsa.pub root@note2:~/
把刚复制的id_rsa.pub加入note2 (不存在authorized_keys则创建):
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
修改权限:chmod 600 ~/.ssh/authorized_keys
重启服务:service ssh restart
配置时区
dpkg-reconfigure tzdata
选择Asia -> 再选择Shanghai -> OKdocker 安装
apt-get update
apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
bash -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
apt-get install docker.io -y
原文链接:https://www.f2er.com/ubuntu/349807.html