ssh及sshd的使用
来源:互联网 发布:淘宝遇到买家恶意退款 编辑:程序博客网 时间:2024/05/29 07:38
一、openssh-server=sshd
功能:让远程主机可以通过网络访问sshd服务,开始一个安全shell
二、客户端连接方式
ssh远程主机用户@远程主机ip
[root@desktop0 ~]# ssh root@172.25.0.11
The authenticity of host '172.25.0.11 (172.25.0.11)' can't beestablished.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? yes ##连接陌生主机时需要建立认证关系
Warning: Permanently added '172.25.0.11' (ECDSA) to the list of knownhosts.
root@172.25.0.11's password: ##远程用户密码
Last login: Mon Oct 3 03:13:472016
[root@server0 ~]# ##登陆成功
ssh远程主机用户@远程主机ip -X ##调用远程主机图形工具
ssh 远程主机用户@远程主机ip command ##直接在远程主机运行某条命令
注:ssh与sshd是客户端(Client)与服务端(Serve)的关系,这种关系是相对的,也是连接与被连接的关系
三、sshkey加密
1.生成公钥私钥
[root@server0 ~]#ssh-keygen ##生成公钥私钥工具
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):[enter] ##加密字符保存文件(建议用默认)
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): [enter] ##密钥密码,必须>4个字符
Enter same passphrase again: [enter] ##确认密码
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is: ab:3c:73:2e:c8:0b:75:c8:39:3a:46:a2:22:34:84:81 root@server0.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|o |
|E. |
|.. |
|. . o |
|.o. * . S |
|oo.o o . |
|+ =. . . |
|o. oo.+.. |
| ..o*. |
+-----------------+
[root@server0 ~]#ls /root/.ssh/
id_rsa id_rsa.pub
id_rsa ##私钥,就是钥匙
id_rsa.pub ##公钥,就是锁
2.添加key认证方式
[root@server0 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.25.0.11
ssh-copy-id ##添加key认证方式的工具
-i ##指定加密key文件
/root/.ssh/id_rsa.pub ##加密key
root ##加密用户为root
172.25.0.11 ##被加密主机ip
3.分发钥匙给client主机
[root@server0 ~]# scp /root/.ssh/id_rsa root@172.25.0.10:/root/.ssh/
4.测试
[root@desktop0 ~]# ssh root@172.25.0.11 ##通过id_rsa直接连接不需要输入用户密码
Last login: Mon Oct 3 03:58:10 2016 from172.25.0.250
[root@server0 ~]#
四、提升openssh的安全级别
1.openssh-server配置文件
vim /etc/ssh/sshd_config
78 PasswordAuthentication yes|no ##是否开启用户密码认证,yes为支持no为关闭
48 PermitRootLogin yes|no ##是否允许超级用户登陆
# 上图为permitRootLogin yes时所产生的效果
# 上图为permitRootLogin no时所产生的效果
49 AllowUsers student westos ##用户白名单,只有在名单中出现的用户可以使用sshd建立shell
50 DenyUsers westos ##用户黑名单
2.控制ssh客户端访问
vim /etc/hosts.deny
sshd:ALL ##拒绝所有人链接sshd服务
vim /etc/hosts.allow
sshd:172.25.254.250 ##允许250主机链接sshd
sshd:172.25.254.250, 172.25.254.180 ##允许250和180链接
sshd:ALL EXCEPT 172.25.254.200 ##只不允许200链接sshd
3.ssh登陆提示修改该
vim /etc/motd ##显示登陆后字符
hello world ##在登陆后就会显示这个字符
- ssh及sshd的使用
- SSHD服务的搭建及使用
- linux sshd ssh 服务的启动和使用
- linux的ssh和sshd配置
- ubuntu下sshd服务与SSH SECURE SHELL CLIENT的使用
- SSHD及应用SCP,SFTP,SSH登录session
- Windows系统中的sshd服务器配置及ssh跳转实现
- Cygwin下配置ssh的问题--sshd服务没启动
- Linux系统之间的网络登录操作ssh与sshd
- ssh的原理及使用
- SSH的配置及使用
- SSH 的命令及使用
- sshd配置文件/etc/ssh/sshd_config
- Ubuntu安装ssh server(sshd)
- linux 9(ssh 和 sshd)
- ssh 使用新法:公网(合法 ip)用户访问内网(私有 ip)服务器(http,ftp,sshd,cvs...),内网的朋友不妨一看。
- [轉貼]sshd 安全設定 ( 設定"禁止使用ssh名單" )
- ssh应用及sudo命令的使用
- Java调用C/C++编写的第三方dll动态链接库(非native API)--- JNI
- construct2的小白入门历程
- node 模块化(简单)
- 注意下string和toString()函数的区别(待写)
- 【Flask】Flask和Django比较
- ssh及sshd的使用
- 计数排序在C++上的实现
- Linux pinctrl subsystem
- Java时间和时间戳的相互转换
- MapReduce的4部分
- 配置交换机的静态路由
- Win7下安装HBase0.96.0单机模式(无需cygwin)
- OC中的 __attribute__
- SaltStack之Pillar和Jinja部署LVS+Keepalived+Haproxy