环境准备Ubuntu18.04
Ubuntu启动服务 systemctl start 服务名
克隆的Ubnutu获取root权限
- 1.首先
sudo passwd root
- 输入两次root的密码
允许使用root用户进行远程登陆
(1)查询系统是否开启了ssh服务
(2)若没有开启,尝试执行 /etc/init.d/ssh start命令
(3)若没有该命令则表明没有安装openssh-server
执行apt-get install openssh-server(普通用户加sudo执行),安装之后再执行开启ssh服务命令
(4)这时我们使用xshell用root用户还是无法登录的,还需要修改/etc/ssh/sshd_config文件
#执行
vim /etc/ssh/sshd_config
#找到
#LoginGraceTime 120
#PermitRootLogin prohibit-password
#StrictModes yes
#改成如下:
#解开掉注释
#Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
(5)然后退出vim编辑,输入命令
/etc/init.d/ssh restart
重启ssh服务即可。
3. 修改主机名
1.修改cloud.cfg防止重启后主机名还原
vi /etc/cloud/cloud.cfg
- 该配置默认为false,修改为true即可
preserve_hostname: true
3.修改主机名
hostnamectl set-hostname 主机名
6.重启计算机
reboot
修改IP
vi编辑器 原样粘贴
先按 Esc 冒号: 输入 set paste 回车再进行粘贴
否则yml格式会错乱
只是为了方便以后的连接防止dbcp随机分配ip
- 1.取root权限
- 2.修改 vim /etc/netplan/50-cloud-init.yaml
- 3.删除所有内容 写入
vim /etc/netplan/50-cloud-init.yaml
network:
version: 2
renderer: networkd
ethernets:
ens33:
addresses:
- 192.168.244.101/24
gateway4: 192.168.244.2
nameservers:
addresses: [8.8.8.8,1.1.1.1]
- 4.重启网络服务 netplan apply