SSH

ssh 服务是实现管路服务器的一种方式:  本地管理(安装系统,故障修复),ssh 远程连接

  linux 可以是实现远程连接的方式:ssh 命令

  windows 可以实现远程连接方式: xshell  、 xmanager 、putty、moba

ssh 的认证方式:  基于用户名、密码、密钥

基于密钥的配置:

  在客户端生成密钥对

  把公钥发送给服务器

linux  提供ssh 服务/ssh 客户端的软件:

[root@localhost ~]# rpm -qa | grep ssh
openssh-7.4p1-11.el7.x86_64
openssh-clients-7.4p1-11.el7.x86_64
openssh-server-7.4p1-11.el7.x86_64

[root@localhost ~]# ss -antp | grep sshd
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1113,fd=3))
LISTEN 0 128 127.0.0.1:6010 *:* users:(("sshd",pid=2084,fd=9))
ESTAB 0 0 192.168.40.100:22 192.168.40.149:62515 users:(("sshd",pid=2415,fd=3))
ESTAB 0 0 192.168.40.100:22 192.168.40.149:62511 users:(("sshd",pid=2084,fd=3))
LISTEN 0 128 :::22 :::* users:(("sshd",pid=1113,fd=4))
LISTEN 0 128 ::1:6010 :::* users:(("sshd",pid=2084,fd=8))

远程连接主机

ssh   +   ip地址(如果做了域名解析,可直接ssh 主机名)

[root@localhost ~]# ssh 192.168.40.100

ssh   +   地址  +  执行的操作

[root@localhost ~]# ssh 192.168.40.100 'hostname'
root@192.168.40.100's password:
server-1

ssh  配置文件

配置文件:/etc/ssh/sshd_config

1) 关闭SSH对主机名的解析

GSSAPIAuthentication no
UseDNS no

[root@node1 ~]# systemctl restart sshd

2) 禁用root用户远程连接

PermitRootLogin no      --(root用户不能远程登录,如果想让root用户可以远程登录设置为yes)

3) 修改默认的SSH端口

Port 22345
ListenAddress 192.168.122.121

关于密钥的设置

在服务器上生成密钥

[root@localhost ~]# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

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:

SHA256:JHnfdLBZthSBhlrujBKsQj+xZFlAktroj39l/PcdXhE root@server-1

The key's randomart image is:

+---[RSA 2048]----+

|  .oo.     ...*o |

|  ..  ..  o oB . |

| +   +o o+ .+ oE |

|o o = o+...o .  .|

|.. + +..S+. .  . |

| .. = .+. o     .|

|  o. .o..      ..|

| . . .   . .  o o|

|  ...     . .. o |

+----[SHA256]-----+

[root@localhost ~]# ls .ssh/

id_rsa  id_rsa.pub  known_hosts

id_rsa       私钥

id_rsa.pub     公钥

如果将本地生成的公钥拷贝到目的主机上下次登录不用输入密码

[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.40.100

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

/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@192.168.40.100's password:

linux基础-ssh服务的更多相关文章

  1. Linux启动ssh服务

    Linux启动ssh服务 在Linux下启动ssh服务使用如下命令其一即可: # service sshd start # /etc/init.d/sshd start 开机启动 使用如下方法其就可以 ...

  2. kali linux 开启ssh服务

    kali linux 一般默认不开启ssh服务,可使用命令查看ssh服务是否开启 命令:service ssh status 如果显示ssh服务没有开启需要修改ssh配置文件将ssh服务开启,kali ...

  3. 查看linux虚拟机ssh服务是否开启

    知识准备: 1.ssh和sshd的区别: 2.ssh服务进程默认地址:/etc/init.d/ssh 查看ssh服务是否开启 service ssh status 或者: /etc/init.d/ss ...

  4. Kali Linux配置ssh服务

    操作环境: 虚拟机操作系统: Kali Linux 2017.2 虚拟化软件: VMware Workstation 14 pro 虚拟机网络连接方式: 桥接模式 物理机操作系统: Windows10 ...

  5. Linux配置ssh服务和XShell连接Linux

    SSH服务查看和安装,配置: https://www.cnblogs.com/qiuqiuqiu/p/6445426.html https://www.cnblogs.com/yunweis/p/77 ...

  6. Linux之ssh服务介绍

    一.什么是SSH? 简单说,SSH(Secure Shell Protocol)是一种网络协议,用于计算机之间的加密登录.在默认状态下SSH服务提供俩个服务功能,一个是提供类似telnet远程联机服务 ...

  7. linux开启ssh服务

    本文概略:1)ubuntu发行版开启ssh.2)centos发行版开启ssh 1.ubuntu发行版安装/开启ssh服务 1.1 安装ssh服务端 sudo apt-get install opens ...

  8. Linux 上SSH 服务的配置和管理

    0.前期准备:清空防火墙,关闭SELinux. [root@localhost ~]# iptables -F #清空防火墙 [root@localhost ~]# /etc/init.d/iptab ...

  9. Linux:SSH服务配置文件详解

    SSH服务配置文件详解 SSH客户端配置文件 /etc/ssh/ssh——config 配置文件概要 Host * #选项“Host”只对能够匹配后面字串的计算机有效.“*”表示所有的计算机. For ...

随机推荐

  1. [C7] 支持向量机(Support Vector Machines) (待整理)

    支持向量机(Support Vector Machines) 优化目标(Optimization Objective) 到目前为止,你已经见过一系列不同的学习算法.在监督学习中,许多学习算法的性能都非 ...

  2. (day55)七、查询优化、MTV和MCV、choices、AJAX、序列化

    目录 一.ORM查询优化 (一)only与defer (1)only (2)defer (二)select_related与prefatch_related (1)select_related (2) ...

  3. php 学习笔记之搭建开发环境(mac版)

    Mac 系统默认集成了很多开发工具,其中就包括 php 所需要的一些软件工具. 下面我们将搭建最简单的 php 开发环境,每一步都会验证上一步的操作结构,请一步一步跟我一起搭建吧! web 服务器之 ...

  4. Eclipse左侧的工程目录消失解决办法

    菜单栏window---->show view--->other--->project explorer

  5. JVM&NIO&HashMap简单问

    JVM&NIO&HashMap简单问 背景:前几天在网上看到关于JVM&NIO&HashMap的一些连环炮的面试题,整理下以备不时之需. 一.JVM Java的虚拟机的 ...

  6. Pytest 使用简介

    前言 最近在听极客时间的课程,里面的讲师极力推崇 pytest 框架,鄙视 unittest 框架,哈哈!然后查了些资料,发现了一条 python 鄙视链:pytest 鄙视 > unittes ...

  7. tensorflow之tf.to_float

    1. tf.to_float()       # 将张量转换为float32类型 2. tf.to_int32()     # 将张量转换为int32类型 等等, 就是将张量转换成某一种类型.

  8. tf.slice()

    原文连接:https://www.jianshu.com/p/71e6ef6c121b tf.slice()到底要怎么切呢?下面通过列子来看看 方程的signature是这样的: def slice( ...

  9. JVM的监控工具之jvisual

    VisualVM(All-in-One Java Trouble shootingTool)是到目前为止随JDK发布的功能最强大的运行监视和故障处理程序,并且可以预见在未来一段时间内都是官方主力发展的 ...

  10. Spring源码系列 — 注解原理

    前言 前文中主要介绍了Spring中处理BeanDefinition的扩展点,其中着重介绍BeanDefinitionParser方式的扩展.本篇文章承接该内容,详解Spring中如何利用BeanDe ...