租服务器
登录服务器配置ssh免密登录方式
修改服务器别名ssh免密登录 安装docker
先登录服务器进入docker官网安装
Set up the repositoryInstall Docker Engine 租服务器
这里是在阿里云租的服务器,咱用的是ECS服务器。
如果是新租的小伙伴,需要在实例中修改密码,这样方便我们在terminal中登录服务器。
登录服务器ssh root@公有IP
首先要adduser,防止在root账户下把服务器搞崩。
$ adduser username # 创建用户username$ usermod -aG sudo username # 给用户username分配sudo权限
退出服务器exit或者ctrl + D
配置ssh免密登录方式 修改服务器别名修改服务器的别名,这里是server1:
进入~/.ssh/
vim config,
Host myserver Hostname IP地址 User acs_1772Host server1 Hostname 共有ip User username
ssh免密登录在自己的terminal中
创建密钥:
$ ssh-keygen
然后一直回车即可。
执行结束后,~/.ssh/目录下会多两个文件:
id_rsa:私钥id_rsa.pub:公钥
然后输入
$ ssh-copy-id 服务器的别名
就会完成ssh免密登录的设置。
具体测试如下:
$ ssh-copy-id server1 # ssh免密登录/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/username/.ssh/id_rsa.pub"/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysusername@公有IP's password: Number of key(s) added: 1Now try logging into the machine, with: "ssh 'server1'"and check to make sure that only the key(s) you wanted were added.
下一次登录只需要使用:
$ ssh server1
不用输入密码。
安装docker 先登录服务器这是我们的服务器:Ubuntu Focal 20.04版本
进入docker官网安装 进入docker官网
https://docs.docker.com/engine/install/ubuntu/
这是我们使用的方法:Install using the repository
我们只需要将命令复制到终端执行即可,下面暂且记录一份
Update the apt package index and install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get update$ sudo apt-get install ca-certificates curl gnupg lsb-release
Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Use the following command to set up the stable repository.
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine$ sudo apt-get update$ sudo apt-get install docker-ce docker-ce-cli containerd.io
经过上面几个步骤,我们的docker就安装完成
$ docker --versionDocker version 20.10.12, build e91ed57