💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
**1.修改主机名** ~~~ [root@shizhan /]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=shizhan ~~~ **2.修改ip地址** >[success] >[root@shizhan ~]# ifconfig eth0 192.168.43.88 重启后无效 ~~~ #永久有效 [root@shizhan /]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 #网卡设备名称 HWADDR=00:0C:29:9A:0B:82 TYPE=Ethernet UUID=b1cbd75d-722e-47a8-82fe-6fb028c84a58 ONBOOT=yes #开机自启动 NM_CONTROLLED=no BOOTPROTO=static #ip地址设置为静态的 IPADDR=192.168.43.66 #ip地址 NETMASK=255.255.255.0 #子网掩码 GATEWAY=192.168.43.2 #网关ip #启动生效 service network restart 或 /etc/init.d/network restart ~~~ **3.修改ip地址和主机名的映射关系** ~~~ [root@shizhan /]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.30.62 server1.test.cn ~~~ **4.关闭selinux** ~~~ [root@shizhan /]# vi /etc/selinux/config SELINUX=disabled [root@shizhan /]# setenforce 0 #生效 ~~~ **5.ssh免密码登录** * linux使用密码远程连接 ~~~ [root@shizhan /]# ssh 192.168.43.68 The authenticity of host '192.168.43.68 (192.168.43.68)' can't be established. RSA key fingerprint is a3:d9:24:47:03:6d:8a:db:0d:f5:66:0a:f4:27:42:4b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.43.68' (RSA) to the list of known hosts. reverse mapping checking getaddrinfo for bogon [192.168.43.68] failed - POSSIBLE BREAK-IN ATTEMPT! root@192.168.43.68's password: Last login: Thu Sep 6 21:36:56 2018 from 192.168.43.1 [root@mini ~]# ls anaconda-ks.cfg install.log install.log.syslog ~~~ * 远程拷贝 ~~~ [root@mini ~]# scp install.log root@192.168.43.68:/home/ #scp 拷贝本地文件到另一台服务器的home目录下 The authenticity of host '192.168.43.68 (192.168.43.68)' can't be established. RSA key fingerprint is a3:d9:24:47:03:6d:8a:db:0d:f5:66:0a:f4:27:42:4b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.43.68' (RSA) to the list of known hosts. reverse mapping checking getaddrinfo for bogon [192.168.43.68] failed - POSSIBLE BREAK-IN ATTEMPT! root@192.168.43.68's password: install.log 100% 23KB 23.1KB/s 00:00 [root@mini ~]# ~~~ * 生成ssh密钥 ~~~ [root@shizhan /]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 66:63:a7:11:cf:08:40:08:13:ff:d5:08:9d:c0:f0:bf root@shizhan The key's randomart image is: +--[ RSA 2048]----+ |+o.==o . | | o...ooo | | . . + o | | . o . = | | . . S + | | = = | | E . | | | | | +-----------------+ [root@shizhan ~]# ll .ssh 总用量 12 -rw-------. 1 root root 1675 9月 6 14:08 id_rsa -rw-r--r--. 1 root root 394 9月 6 14:08 id_rsa.pub -rw-r--r--. 1 root root 798 9月 6 13:44 known_hosts ~~~ * 拷贝密钥到服务器上 ~~~ [root@mini .ssh]# ssh 192.168.43.66 #先连接生成密钥的66服务器 root@192.168.43.66's password: Last login: Wed Sep 5 14:42:25 2018 from 192.168.43.1 [root@shizhan ~]# cd .ssh [root@shizhan .ssh]# ll total 12 -rw-------. 1 root root 1675 Sep 6 14:08 id_rsa -rw-r--r--. 1 root root 394 Sep 6 14:08 id_rsa.pub -rw-r--r--. 1 root root 798 Sep 6 13:44 known_hosts [root@shizhan .ssh]# ssh-copy-id 192.168.43.68 #拷贝密钥到另一台68服务器 reverse mapping checking getaddrinfo for bogon [192.168.43.68] failed - POSSIBLE BREAK-IN ATTEMPT! root@192.168.43.68's password: Now try logging into the machine, with "ssh '192.168.43.68'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. [root@shizhan .ssh]# exit #退出生成密钥的66服务器 logout Connection to 192.168.43.66 closed. [root@mini .ssh]# ll total 8 -rw-------. 1 root root 452 Sep 6 22:18 authorized_keys -rw-r--r--. 1 root root 790 Sep 6 21:52 known_hosts [root@mini .ssh]# cat authorized_keys #查看拷贝到68服务器的密钥 ~~~ * 在66服务器上免密码连接68服务器 ~~~ [root@shizhan .ssh]# ssh 192.168.43.68 Last login: Thu Sep 6 21:44:50 2018 from 192.168.43.66 [root@mini ~]# ~~~ * 根据hostname 登录 ~~~ [root@shizhan ~]# vi /etc/hosts #在66服务上添加 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.43.68 mini [root@shizhan ~]# ssh mini #直接根据hostname登录 Last login: Thu Sep 6 23:03:07 2018 from shizhan ~~~ **6.修改开机等待时间** ~~~ [root@mini grub]# vi /boot/grub/grub.conf timeout=0 ~~~ **7.解决克隆后eth0不见的问题** >[danger] 直接修改 /etc/sysconfig/network-script/ifcfg-eth0 >删掉UUID HWADDR >配置静态地址 >然后 rm -rf /etc/udev/rules.d/70-persistent-net.rules 获者修改这个文件将eth1改为eth0 将原来eth0的删掉。 >然后reboot > ①查看和配置网络设备 ~~~ [root@shizhan ~]# ifconfig -a eth1 Link encap:Ethernet HWaddr 00:0C:29:9A:0B:82 inet addr:192.168.43.66 Bcast:192.168.43.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe9a:b82/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:32546 errors:0 dropped:0 overruns:0 frame:0 TX packets:4276 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2168414 (2.0 MiB) TX bytes:787699 (769.2 KiB) ~~~ ②删掉UUID HWADDR ~~~ [root@shizhan ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static IPADDR=192.168.43.66 NETMASK=255.255.255.0 GATEWAY=192.168.43.2 ~~~ ③编辑/etc/udev/rules.d/70-persistent-net.rules 将原来的eth0删掉 将eth1 改为eth0 并reboot ~~~ [root@shizhan ~]# vi /etc/udev/rules.d/70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x8086:0x100f (e1000) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9a:0b:82", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" ~~~