sshd使用
sshd服务
1.sshd介绍
sshd为secure shell的简称;可以通过网络在主机中开机shell的服务
连接方式(在客户端):ssh username@ip #文本模式
ssh -X username@ip #可以在链接成功后开启图形界面
注意:
第一次链接陌生主机是要建立认证文件,然后会询问是否建立,需要输入yes
再次链接此台主机时,因为已经生成~/.ssh/know_hosts文件所以不需要再次输入yes
远程复制: 格式 scp file root@id:dir(文件的上传)
scp root@if:/dir file(文件的下载)
- 示例:把177主机下/mnt/file1文件上传到 172.25.254.97主机的/root/Desktop/目录下:
[root@localhost mnt]# ls niu/
file1 file2 file3 file4 file5
[root@localhost mnt]# scp niu/file1 root@172.25.254.97:/root/Desktop/
file1 100% 0 0.0KB/s 00:00
此时可以在97主机下的桌面上看到file1:
[root@localhost Desktop]# ls
file1
- 示例:把97主机桌面下的file文件下载到177主机的/mnt/目录下:
file 100% 0 0.0KB/s 00:00
此时可以在177主机上/mnt/目录下可以看到file文件
file niu root@172.25.254.97
2.sshd 的key认证
【1】生成认证KEY
生成密钥的命令:ssh-keygen
[root@localhost ~]# ls -a
. .bash_logout .config Downloads Music Templates
.. .bash_profile .cshrc .esd_auth Pictures Videos
anaconda-ks.cfg .bashrc Desktop .ICEauthority Public .viminfo
.bash_history .cache Documents .local .tcshrc
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
8c:23:ee:39:11:6b:e6:af:a3:76:b1:00:a5:6e:d1:d3 root@localhost
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . |
| o. . |
|o. o.E o |
|... ooo S |
| o..*. . |
|. =.+ |
| ..*. |
| ..o+=. |
+-----------------+
【2】加密服务
使用命令:ssh-copy-id -i /root/.ssh/id_rsa.pub root@id
[root@localhost .ssh]# ls
id_rsa id_rsa.pub
The authenticity of host '172.25.254.97 (172.25.254.97)' can't be established.
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
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@172.25.254.97's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@172.25.254.97'"
and check to make sure that only the key(s) you wanted were added.
authorized_keys id_rsa id_rsa.pub known_hosts
(此时authorized_keys文件,生成代表97主机加密成功;id-rsa为钥匙,id_rsa.pub为锁)
【3】分发钥匙
使用命令: scp /root/.ssh/id_rsa root@id:/root/.ssh/
authorized_keys id_rsa id_rsa.pub known_hosts
[root@localhost .ssh]# scp id_rsa root@172.25.254.177:/root/.ssh/
The authenticity of host '172.25.254.177 (172.25.254.177)' can't be established.
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.254.177' (ECDSA) to the list of known hosts.
root@172.25.254.177's password:
id_rsa 100% 1679 1.6KB/s 00:00
**在177主机下进行验证:
id_rsa known_hosts
【4】测试
在客户主机中(172.25.254.177)输入命令:ssh root@172.25.254.97
Last login: Wed Jul 25 23:10:43 2018
此时不需要进行root用户的登陆,直接连接成功
3.sshd的安全设定
PasswordAuthentication yes|no ##是否允许用户通过登陆系统的密码做sshd的认证,(在78行也可登录其他用户密码)
PermitRootLogin yes|no ##是否允许root用户通过sshd服务的认证(48行)
Allowusers student westos ##设定用户白名单,白名单出现默认不再名单中的用户不能使用sshd
Denyusers westos ##设定用户黑名单,黑名单出现默认不再名单中的用户可以使用sshd
注意:在服务端修改文件的配置:vim /etc/ssh/sshd_config
配置完成之后要重启服务:systemctl restart sshd.service
此文为装载
sshd使用的更多相关文章
- sshd 指定端口,指定秘钥文件
scp -i ~/test -P22219 SRC/ root@10.2.227.76:/data/ #sshd的端口指定的是22219, -i 指定秘钥文件 指定秘钥文件需要注意的是,需要提 ...
- SSHD服务搭建
SSH协议:安全外壳协议.为Secure Shell 缩写.SSH为建立在应用层和传输层基础上的安全协议. 1.检查SSH服务端安装情况 [root@rhel6_84 ~]# rpm -qpi / ...
- sshd 错误
140669086946976:error:0E079065:configuration file routines:DEF_LOAD_BIO:missing equal sign:conf_def. ...
- 开源服务专题之------sshd服务安装管理及配置文件理解和安全调优
本专题我将讨论一下开源服务,随着开源社区的日趋丰富,开源软件.开源服务,已经成为人类的一种公共资源,发展势头可谓一日千里,所以不可不知.SSHD服务,在我们的linux服务器上经常用到,很重要,涉及到 ...
- sshd安装
centos yum install openssh-server #chkconfig --level 2345 sshd on #service sshd restart 重新启动 #netsta ...
- [Linux] 学习笔记之安装学习环境(sshd, lrzsz)
紧接前一篇,在VMWare安装完Linux,这个时候我们要使用远程工具连接到虚拟机上去了,以前一直使用Putty,后来到新公司之后,推荐使用SecureCRT,使用之后,觉得效果不错,但是每次连接都失 ...
- BackTrack 5 开启SSHD服务
BackTrack 5 开启SSHD服务 1 service ssh start 但启动后,仍然无法从远程连接,会有提示: 1 Read from socket failed: Connection ...
- linux防止sshd被爆破(安装denyhosts)
这是一篇收集在日志里的文档,当初查看服务器sshd日志发现很多不明IP尝试登陆,因此想用什么办法阻止这样的事情发生.网上找了下用denyhosts可以解决这样的问题,因而也就将其收集在日志里了.由于时 ...
- Fedora 启动sshd服务:
.先确认是否已安装ssh服务: [root@localhost ~]# rpm -qa | grep openssh-server openssh-server-.3p1-.fc12.i686 (这行 ...
- 改变服务器sshd 的22的端口
[root@v01-svn-test-server ~]# vi /etc/ssh/sshd_config Port 22 Port 5001 #新增加5001端口给sshd,现在22,5001都是s ...
随机推荐
- nginx重新编译安装upload模块
由于php处理上传会出现超时,并且显示上传进度官方php不支持nginx+php,所以决定让nginx自己处理上传,我本地环境是mac上已经安装过nginx1.8.0,安装方式为brew,所以需要重新 ...
- PHP之简单工厂模式(二)
定义 简单工厂模式,通过定义一个工厂类,负责完成类实例的创建,根据参数的不同返回不同的类实例.对外部来讲,只需传入一个正常的参数就可以获得想要的对象,而不必需要具体创建细节.创建类实例的方法通常为静态 ...
- tensorflow学习笔记五----------逻辑回归
在逻辑回归中使用mnist数据集.导入相应的包以及数据集. import numpy as np import tensorflow as tf import matplotlib.pyplot as ...
- “程序包com.sun.tools.javac.util不存在” 问题解决
最近工作中在编译打包项目的时候遇到了如标题所示的问题,报这个错误的类是 com.sun.tools.javac.util.Pair.问题很诡异,在Idea可以导入此类,项目启动运行也很正常,但就是在打 ...
- [IIS]修改MaxFieldLength与MaxRequestBytes彻底解决Request Too Long的问题
当 IIS7/7.5 收到的请求头的长度超过16K(默认值),就会引发"Bad Request - Request Too Long. HTTP Error 400. The size of ...
- Python 中的Lock与RLock
摘要 由于多线程共享进程的资源和地址空间,因此,在对这些公共资源进行操作时,为了防止这些公共资源出现异常的结果,必须考虑线程的同步和互斥问题. 为什么加锁:1.用于非线程安全, 2.控制一段代码,确保 ...
- UIAlertView, UIAlertViewController
iOS 8的新特性之一就是让接口更有适应性.更灵活,因此许多视图控制器的实现方式发生了巨大的变化.全新的UIPresentationController 在实现视图控制器间的过渡动画效果和自适应设备尺 ...
- React Autocomplete(自动完成输入)示例教程
React Autocomplete示例教程是今天的主题.在现代Web开发中,使用React改善用户体验是很容易.自动完成的概念很简单.它是基于用户输入的建议列表.然后,用户可以按Enter键以完成短 ...
- ppt打不开,显示发现文件中的内容有问题。可尝试修复此演示文稿
原因分析 主要是因为文件是网络下载的,office自动锁定了文件(默认不可编辑). 解决办法 在文件上右键-属性-解除锁定(最下面),就不会进行检查了,问题也就解决了. ppt文件---右键---属性 ...
- Python图谱
Reference: https://time.geekbang.org/column/article/94311