CentOS 远程登录(以下root必须以用户进行操作  ,

文本编辑:vi 文件名 打开文本  、i 进行编辑、Esc退出编辑状态、:wq保存并退出 、:q!直接退出、cat 文件名 查看文本内容

su 用户名 切换用户、sudo 命令直接使用root权限进行操作)


1.root 登录

a.允许root直接登录

vi /etc/pam.d/gdm 

去掉#号(去注释):#auth required pam_succeed_if.so user != root quiet


b.允许root通过ssh远程登录

vi /etc/ssh/sshd_config 

修改  :PermitRootLogin    yes

重启ssh服务  :/etc/rc.d/init.d/sshd restart  PS:如果重启后还是不行请重新载入sshd_config 文件

/etc/rc.d/init.d/sshd reload


c root自动登录

vi  /etc/gdm/custom.conf 

AutomaticLoginEnable=true 这个修改为 true 

AutomaticLogin=root              这个修改为 root 

TimedLogin=root                     这个修改为 root 



2.普通用户登录

新建用户:useradd -d /usr/momo -m momo

设置密码:passwd momo

(给momo赋root权限) 以下操作需要修改文件读写权限:chmod 777 /etc/sudoers 修改后需要还原 :chmod 440 /etc/sudoers

方法一:修改 /etc/sudoers 文件,找到下面一行,把前面的注释(#)去掉

## Allows people in group wheel to run all commands

%wheel    ALL=(ALL)    ALL

然后修改用户,使其属于root组(wheel),命令如下:

#usermod -g root tommy

方法二:修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:

## Allow root to run any commands anywhere

root    ALL=(ALL)     ALL

tommy   ALL=(ALL)     ALL


3.安装ftp

安装  yum -y install vsftpd

开启服务: service vsftpd start;      开机自启 :chkconfig vsftpd on;


注:centos 防火墙 iptables

       ubuntu 防火墙 ufw

4.防火墙开放端口号:

22 21 80 8080等常用端口

/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT 新建规则

/etc/rc.d/init.d/iptables save 保存