【运维笔记】Ubuntu环境初始化
初始化root密码
app@manager:~$ sudo passwd
[sudo] password for app:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
app@manager:~$ su
Password:
root@manager:/home/app#
开启root远程登录
# 修改配置文件
root@manager:/home/app# vi /etc/ssh/sshd_config
# 找到 PermitRootLogin prohibit-password
# 修改为下面的内容
PermitRootLogin yes
# 保存并重启ssh
# 更换服务器,使用ssh登录
root@ubuntu:~# ssh 192.168.0.117
The authenticity of host '192.168.0.117 (192.168.0.117)' can't be established.
ECDSA key fingerprint is SHA256:2NtdloRfkAB7IGA4lfyVw3mv4n+8okxSdAKmh+eHohE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.117' (ECDSA) to the list of known hosts.
root@192.168.0.117's password:
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-62-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
230 packages can be updated.
144 updates are security updates.
New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Thu Jan 31 10:38:58 2019 from 192.168.0.115
root@manager:~#
配置静态ip
# 先查看本机网络信息
root@manager:~# ifconfig
ens160 Link encap:Ethernet HWaddr 00:0c:29:a5:6d:f6
inet addr:192.168.0.117 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea5:6df6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:378 errors:0 dropped:0 overruns:0 frame:0
TX packets:190 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:43702 (43.7 KB) TX bytes:24447 (24.4 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:160 errors:0 dropped:0 overruns:0 frame:0
TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:11840 (11.8 KB) TX bytes:11840 (11.8 KB)
# 修改配置文件
root@manager:~# vi /etc/network/interfaces
# 修改为:
auto ens160
iface ens160 inet static
address 192.168.0.40
netmask 255.255.255.0
gateway 192.169.0.1
dns-nameserver 192.168.0.1
# 保存,并重启服务器
root@manager:~# reboot -h now
root@manager:~# ifconfig
ens160 Link encap:Ethernet HWaddr 00:0c:29:a5:6d:f6
inet addr:192.168.0.40 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea5:6df6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:196 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16991 (16.9 KB) TX bytes:8294 (8.2 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:160 errors:0 dropped:0 overruns:0 frame:0
TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:11840 (11.8 KB) TX bytes:11840 (11.8 KB)
root@manager:~# ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=55 time=30.2 ms
64 bytes from 180.97.33.107: icmp_seq=2 ttl=55 time=32.5 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=55 time=29.8 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 29.827/30.876/32.551/1.196 ms
全部评论