zoukankan      html  css  js  c++  java
  • ssh命令使用

    ssh是什么

    ssh是一种通信协议,用于与另一台计算机通信,有多个实现版本,openssh属于开源实现

    usage: ssh [-B bind_interface]
               [-b bind_address] 
               [-c cipher_spec] 
               [-D [bind_address:]port]
               [-E log_file] 
               [-e escape_char] 
               [-F configfile] 
               [-I pkcs11]
               [-i identity_file] 
               [-J [user@]host[:port]] 
               [-L address]
               [-l login_name] 
               [-m mac_spec] 
               [-O ctl_cmd] 
               [-o option] 
               [-p port]
               [-Q query_option] 
               [-R address] 
               [-S ctl_path] 
               [-W host:port]
               [-w local_tun[:remote_tun]] destination [command]
    
    //root账户登录
    ssh xxx.xxx.xxx 
    
    //指定用户 -l
    ssh -l root xxx.xxx.xxx
    ssh root@xxx.xxx.xxx
    
    //指定端口 -p
    ssh -p 123 xxx.xxx.xxx or
    ssh -l root -p 123 xxx.xxx.xxx or
    ssh -p 123 root@xxx.xxx.xxx
    

    中间人攻击

    假设有中间人冒充用户主机的情况

    口令登录

    $ ssh user@host
      The authenticity of host 'host (xxx.xxx.xxx.xxx)' can't be established.
      RSA key fingerprint is 98:2e:d7:e0:de:9f:ac:67:28:c2:42:2d:37:16:58:4d.
      Are you sure you want to continue connecting (yes/no)?
      
    //基于中间人攻击问题,所以第一次登录无法确认主机安全性,可以根据RSA加密提供的key与远程主机的公钥进行对比
    
    

    登录成功后

    $ cat ~/.ssh/known_hosts
    
    //用户系统会自动把当前公钥存起来
    //下次连接这台主机时就知道这台主机的身份了,跳过警告部分
    
    

    登录失败的情况

    //因为密码输错了,所以登录不了
    root@xxx.xxx.xx password: 
    Permission denied, please try again.
    
    

    公/私钥对

    公钥和私钥是成对的,它们互相解密。
    
    公钥加密,私钥解密。
    
    私钥数字签名,公钥验证。
    

    公钥登录

    $ ssh-keygen
    //一路回车在~/.ssh/下生成2把钥匙
    
    $ ssh-copy-id user@host
    //将公钥传到主机
    
    //公钥被放在 ~/.ssh/authorized_keys 
    

    失败解决

    // ubuntu系统 ssh进程重启命令
    service ssh restart
    // debian系统 ssh进程重启命令
    /etc/init.d/ssh restart
    
    
  • 相关阅读:
    mysql router读写分离
    Hbase单节点Standalone & Pseudo Distribute
    WAS web.xml修改不生效
    Hadoop单节点集群
    网易云音乐 linux版
    OpenLDAP GUI管理工具
    Memcached源码安装配置
    CentOS7 /var/log/messages Starting Session x of user root
    linux下安装jdk(转载)
    ubuntu安装rpm格式文件方法(转载)
  • 原文地址:https://www.cnblogs.com/pluslius/p/9890679.html
Copyright © 2011-2022 走看看