Linux服务

来源:互联网 发布:数据库事务特性 编辑:程序博客网 时间:2024/06/01 10:19

1.什么是服务?

service

在系统中提供某项服务的软件

 

2.服务管理,systemctl命令

systemctl start 服务名  ###开启服务

systemctl stop 服务名  ###关闭服务

systemctl restart 服务名  ###重启服务

systemctl reload 服务名  ###重新加在服务配置

systemctl status 服务名  ###查看服务状态

systemctl enable 服务名  ###设定服务开机启动

systemctl disable 服务名  ###禁止服务开机启动

set-default multi-user.target 服务名  ###开机不启动图形

set-default graphical.target 服务名  ###开机启动图形

 [liu@localhost Desktop]$ rht-vmctl start desktop

 [liu@localhost Desktop]$ rht-vmctl view desktop

[liu@localhost Desktop]$ rht-vmctl status desktop

[liu@localhost Desktop]$ rht-vmctl poweroff desktop 

3.sshkey认证

#######生成key###########

 ssh-keygen  ###生成公钥和私钥(在服务端),/root/.ssh (生成密钥存放位置),id_rsa位私钥,id_rsa.pub位公钥 

 ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.126

 ##192.168.1.126提供服务的ip,ssh-copy-id key的工具-i (指定使用的公钥)

 ##/root/.ssh/id_rsa.pub 公钥root被管理的用户

 ##authorized_keys ###此文件在目标用户加目录的.ssh中,这个文件就是目标用户被加密的标识,文件内容位公钥内容。

scp /root/.ssh/id_rsa root@192.168.1.125##把秘钥给客


sshd服务的简单配置

vim /etc/ssh/sshd_config ###sshd服务的配置文件

 PermitRootLogin yes|no  ###是否允许root用户通过sshd的认证,48行

 PasswordAuthentication yes|no ###开启或关闭用户密码认证,78行

AllowUsers student westos ###用户白名单,只允许在名单中出现的用户使用sshd服务

systemctl restart sshd ###从新加载配置

 

 

 

 

 

 

 

 

 


0 0
原创粉丝点击