1. 程式人生 > >修改CentOS主機名

修改CentOS主機名

修改CentOS主機名

1.開啟network檔案

[[email protected] ~]# vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=yxy(你要修改的主機名)

2.修改系統主機表文件

[[email protected] ~]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1    yxy      localhost.localdomain localhost4 localhost4.localdomain4(增加這一行)

3.重啟系統

 [[email protected] ~]# reboot



Broadcast message from [email protected]

        (/dev/pts/0) at 0:20 ...



The system is going down for reboot NOW!

[[email protected] ~]#             

 

設定免密登入

設定免密登入:

[[email protected] ~]# ssh-keygen  (按3個回車)

[[email protected] ~]# ssh-copy-id yxy(主機名)  1032763126(密碼)

若出現-bash: ssh-copy-id: command not found   

先用命令安裝

[[email protected] ~]# yum -y install openssh-clients

安裝之後再用

[[email protected]
~]# ssh-copy-id yxy  1032763126

測試免密登入是否生效:

[[email protected] ~]# ssh yxy