zoukankan      html  css  js  c++  java
  • ssh

    sshd服务讲解
     
    SSHD服务
    介绍:SSH 协议:安全外壳协议。为 Secure Shell 的缩写。SSH 为建立在应用层和传输层基础上的安全协议。
    默认端口22
     
    作用
    sshd服务使用SSH协议可以用来进行远程控制, 或在计算机之间传送文件 
    相比较之前用telnet方式来传输文件要安全很多,因为telnet使用明文传输,是加密传输。
    SSH服务安装
    这里用yum安装(系统已经默认安装并开机自启
    SSH 配置文件
    SH 常用配置文件有两个/etc/ssh/ssh_config 和/etc/sshd_config。
    ssh_config 为客户端配置文件
    sshd_config 为服务器端配置文件
    Xshw

    DNS不解析快速链接

    ─root@zxw /mnt 
    ╰─➤ vim /etc/ssh/sshd_config
    UseDNS no


     

     
    使用ssh免密登录远程主机
     
    1、ssh [远程主机用户名] @[远程服务器主机名或IP地址]
    如果用root进程登录远程主
    ╭─root@zxw /mnt 
    ╰─➤ ssh 192.168.126.9 
    第一次登录服务器时系统没有保存远程主机的信息,为了确认该主机身份会提示用户是否继续连
    接,输入yes 后登录,这时系统会将远程服务器信息写入用户主目录下的$HOME/.ssh/known_hosts 文件中,下次再进行登录时因为保存有该主机信息就不会再提示了

     
    输入ssh-keygen之后一直回车即可,生成一次即可,无需多次生成该密钥,否则会提示你是否覆盖选项!
     
    发送密钥
    ╭─root@zxw /mnt 
    ╰─➤ 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:
    e3:a5:a1:96:7b:3e:d2:67:34:39:4b:22:22:27:98:23 root@zxw
    The key's randomart image is:
    +--[ RSA 2048]----+
    | |
    | |
    | |
    | |
    | o S .. |
    |E o o .+.=* |
    |.. + .+oo+ + |
    | ...+ + |
    | .+.+ |
    +-----------------+

    第二步:查看生成的秘钥
    ╭─root@zxw ~ 
    ╰─➤ ls .ssh
    id_rsa id_rsa.pub known_hosts

    id_rsa:                         私钥(执行ssh-keygen生成)
    id_rsa.pub:                  公钥(执行ssh-keygen生成
    known_hosts:              主机信息

     
    使用ssh-copy-id加上ip地址即可传送密钥至想要登录的主机,需要输入一次客户端的密码
    added.

     

    ssh-copy-id 192.168.126.9
    /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.126.9's password: 
    Permission denied, please try again.
    root@192.168.126.9's password:

    Number of key(s) added: 1

    Now try logging into the machine, with: "ssh '192.168.126.9'"
    and check to make sure that only the key(s) you wanted were added.

     

    第四步:免密登录
    ╭─root@zxw ~ 
    ╰─➤ ssh 192.168.126.9

    登录节点
     
    在发送完密钥之后即可不需要输入密码即可访问节点
    如果节点不是默认的22端口,还需要机上小写 的p选项指定端口

  • 相关阅读:
    Maxwell的vbs脚本转matlab
    maxwell电机直观理解
    maxwell电机转矩扫描与使用MTPA策略绘制效率map图
    maxwell施加均匀外磁场
    maxwell的那些坑&小技巧
    maxwell主从边界
    MySql基础
    数据结构知识结构框架图
    第八章 多线程
    软件
  • 原文地址:https://www.cnblogs.com/itzhao/p/11253860.html
Copyright © 2011-2022 走看看