修改CentOS主机名

修改CentOS主机名

1.打开network文件

[root@yxy ~]# vi /etc/sysconfig/network

NETWORKING=yes

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

2.修改系统主机表文件

[root@yxy ~]# 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.重启系统

 [root@yxy ~]# reboot



Broadcast message from root@yxy

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



The system is going down for reboot NOW!

[root@yxy ~]#             

 

设置免密登录

设置免密登录:

[root@yxy ~]# ssh-keygen  (按3个回车)

[root@yxy ~]# ssh-copy-id yxy(主机名)  1032763126(密码)

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

先用命令安装

[root@yxy ~]# yum -y install openssh-clients

安装之后再用

[root@yxy ~]# ssh-copy-id yxy  1032763126

测试免密登录是否生效:

[root@yxy ~]# ssh yxy

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 博客之星2020 设计师:CY__0809 返回首页