Ubuntu 配置 ssh 免密连接、安装Docker、docker-compose
Ubuntu 配置 ssh 免密连接
#生成密钥
ssh-keygen -t rsa -b 4096
#发送公钥到服务器
ssh-copy-id username@remote_host
#测试
ssh username@remote_host
全部回车,密钥存储路径默认是 ~/.ssh/id_rsa
服务器公钥配置允许远程公钥认证
sudo vim /etc/ssh/sshd_config
设置 PubkeyAuthentication yes
sudo systemctl restart ssh
本机设置别名
vim ~/.ssh/config
Host name
HostName IP地址
Port ssh端口号
User root用户名
PassWordAuthentication yes 使用密码身份验证
sudo systemctl restart ssh
Ubuntu 安装 Docker
一键安装
没有特殊需求直接安装 Docker 的一个 Ubuntu 软件包版本
sudo apt update && sudo apt upgrade && sudo apt install -y docker.io
service docker start
sudo systemctl enable docker
sudo systemctl is-enabled docker
配置Docker镜像源
sudo vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://docker.1panel.live"
]
}
sudo systemctl restart docker
docker info
docker run hello-world
Ubuntu 安装 docker-compose
本机下载一个最新对应版本重命名为 docker-compose传到服务器上
scp ./docker-compose root@IP:/usr/bin/
服务器赋权限
chomod +x /usr/bin/docker-compose
PS
docker logs 容器ID -f
UP!
原文地址:https://blog.csdn.net/Xiao_tongtong/article/details/142825914
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!