Linux服务器---ssh登录

news/2024/7/9 2:24:05 标签: Linux, ssh

Ssh登录    

        Ssh是建立在应用层和传输层的安全协议,专门为远程登录回话和其他网络服务提供安全性。利用ssh可以有效的防止远程管理中的信息泄露问题,同时ssh传输的数据是经过压缩的,可以加快传输速度。

 

1、启动sshd服务。Centos默认已经安装了ssh,而且该服务默认是启动的

[root@localhost wj]# rpm -qa | grep ssh

libssh2-1.4.2-1.el6.i686

openssh-askpass-5.3p1-94.el6.i686

openssh-server-5.3p1-94.el6.i686

openssh-clients-5.3p1-94.el6.i686

openssh-5.3p1-94.el6.i686

[root@localhost wj]# service sshd status

openssh-daemon (pid  1634) 正在运行...

[root@localhost wj]# 

 

2、测试登录

[root@localhost wj]# ssh root@192.168.0.119

The authenticity of host '192.168.0.119 (192.168.0.119)' can't be established.

RSA key fingerprint is 36:20:c9:ab:88:1f:47:74:1b:f1:d7:47:55:e0:14:7c.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.0.119' (RSA) to the list of known hosts.

root@192.168.0.119's password: 

Last login: Fri Aug 10 14:57:45 2018

already login

[root@localhost ~]# exit

logout

Connection to 192.168.0.119 closed.

 

3、禁止root登录

        root用户在Linux系统中拥有最高的权利,如果用root用户登录就意味着增大了系统的风险。Ssh默认可以使用root登录,为了安全考虑,我们可以禁止root登录。

        1)修改配置文件“/etc/ssh/sshd_config”,找到“permitRootLogin”将其改为no 

[root@localhost wj]# gedit /etc/ssh/sshd_config 

PermitRootLogin no    //这里默认是yes,而且已经被注释掉了。取消注释,改为no

 

[root@localhost wj]# service sshd restart           //重启服务

停止sshd                                               [确定]

正在启动sshd                                            [确定]

[root@localhost wj]# 

        2)测试,使用root登录,可以看到没有权利

[root@localhost wj]# ssh root@192.168.0.119

root@192.168.0.119's password: 

Permission denied, please try again.

 

4、设置指定用户登录

        有时候为了降低系统风险,我们还会设置指定的用户登录,而其他用户登录就会拒绝。

        1)修改配置文件“/etc/ssh/sshd_config”,在最后追加

[root@localhost wj]# gedit /etc/ssh/sshd_config 

AllowUsers david    //允许david登录

 

[root@localhost wj]# service sshd restart           //重启服务

停止sshd                                               [确定]

正在启动sshd                                            [确定]

[root@localhost wj]#

        2)测试,分别使用david和weijie两个用户登录,其中weijie会登录失败

[root@localhost wj]# ssh weijie@192.168.0.119

weijie@192.168.0.119's password: 

Permission denied, please try again.

 

[root@localhost wj]# ssh david@192.168.0.119

david@192.168.0.119's password: 

Last login: Wed Aug 15 17:12:59 2018 from 192.168.0.112

already login

 

做了一个Linux学习的平台,目前出来一个个形,各位可以参考使用
链接:https   ://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ密码:n7bk


http://www.niftyadmin.cn/n/1090318.html

相关文章

HashTable集合遍历的三种方法

hashtable集合遍历可以根据key,value以及keyvalue 示例代码: Hashtable table new Hashtable(); Student stu new Student(); stu.Name "李四"; stu.Age 18; Student stu1 new Student(); stu1.Name "张三"; stu1.Age 18; St…

c语言sample等价错误,c语言 新手 请问我的代码哪里错了,运行正确,提交就是不对...

Description华神敲着敲着代码突然断网了,无所事事,闲的蛋疼,没办法他打开时间表数时间玩,然后突然之间发现了自己一个神奇的技能,他可以在很短的时间内算出两个日期之间的间隔时间,他自己觉得很吊&#xff…

LstrcmpAPI函数Hook技术逆向分析

LstrcmpAPI函数Hook技术逆向分析 API Hook技术简介 API Hook通过修改API函数的起始地址,使之跳转到自己定义的函数,通过自己定义的函数实现自己想要实现的功能 API Hook实现的过程如下: 获取API函数的地址修改API函数起始地址的字节&#…

在知乎上看到的几个关于C的奇淫技巧

有一个鲜为人知的运算符叫”趋向于”&#xff0c; 写作“-->”。比如说如果要实现一个倒数的程序&#xff0c;我们可以定义一个变量x&#xff0c;然后让它趋向与0&#xff1a; 输出&#xff1a; 然后我们把 "x-->0" 换个方向&#xff0c;变成 "0<--x&q…

Linux服务器---ssh配置

Ssh配置 通过配置文件&#xff0c;我们可以有效的管理ssh 1、空闲时间关闭连接 1&#xff09;修改配置文件“/etc/ssh/sshd_config”&#xff0c;设置clientAliveInterval和clientAliveCountMax&#xff0c;注意取消前面的注释 [rootlocalhost wj]# gedit /etc/ssh/sshd_c…

改变滚动条的样式

<!doctype html> <html lang"en"> <head><meta charset"UTF-8"><title>改变滚动条默认样式</title><style>*{margin: 0;padding: 0;}/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/::-webkit-scrollba…

Linux基础命令---unzip

unzip 解压zip指令压缩过的文件。unzip将列出、测试或从ZIP存档中提取文件&#xff0c;这些文件通常在MS-DOS系统中找到。默认行为(没有选项)是将指定ZIP存档中的所有文件提取到当前目录(及其下面的子目录)中。一个配套程序zip(1L)创建ZIP档案&#xff1b;这两个程序都与PKWare…

pta比较大小c语言,福大pta--C语言--选择结构程序设计

1 计算个人所得税选择假设个人所得税为&#xff1a;税率(工资−1600)。请编写程序计算应缴的所得税&#xff0c;其中税率定义为&#xff1a;当工资不超过1600时&#xff0c;税率为0&#xff1b;当工资在区间(1600, 2500]时&#xff0c;税率为5%&#xff1b;当工资在区间(2500, …