更改计算机名及使用Secure CRT ssh连接用户添加方法汇总

修改计算机名
更改/etc/sysconfig下的network文件,在提示符下输入vi /etc/sysconfig/network
然后将HOSTNAME后面的值改为想要设置的主机名。

 开启SSH 超时自动断开

修改/etc/ssh/sshd_config文件,找到 ClientAliveInterval 0和ClientAliveCountMax 3并将注释符号("#")去掉,
ClientAliveInterval 指定了服务器端向客户端请求消息的时间间隔, 默认是0, 不发送.
修改为

ClientAliveInterval 60  表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了.
ClientAliveCountMax 3, 使用默认值3即可.ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开.
正常情况下, 客户端不会不响应.

重起sshd服务

service sshd restart

设置允许使用SSH 连接的用户方法汇总

正好有朋友问,就转过来分享下。

转自:http://blog.sina.com.cn/s/blog_6fc583e70100n6rm.html

测试环境:CentOS 5.5

1、添加用户,首先用adduser命令添加一个普通用户,命令如下:

#adduser tommy 
//添加一个名为tommy的用户
#passwd tommy   //修改密码
Changing password for user tommy.
New UNIX password:     //在这里输入新密码
Retype new UNIX password:  //再次输入新密码
passwd: all authentication tokens updated successfully.

2、赋予root权限

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

## Allows people in group wheel to run all commands
%wheel    ALL=(ALL)    ALL

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

#usermod -g root tommy

修改完毕,现在可以用tommy帐号登录,然后用命令 su - ,即可获得root权限进行操作。

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

## Allow root to run any commands anywhere
root    ALL=(ALL)     ALL
tommy   ALL=(ALL)     ALL

修改完毕,现在可以用tommy帐号登录,然后用命令 su - ,即可获得root权限进行操作。

方法三: 修改 /etc/passwd 文件,找到如下行,把用户ID修改为 0 ,如下所示:

tommy:x:500:500:tommy:/home/tommy:/bin/bash

修改后如下

tommy:x:0:500:tommy:/home/tommy:/bin/bash

保存,用tommy账户登录后,直接获取的就是root帐号的权限。

友情提醒:虽然方法三看上去简单方便,但一般不推荐使用,推荐使用方法二。

原文地址:https://www.cnblogs.com/qzqdy/p/8031657.html