• SSH 远程连接


    ssh远程连接

    准备工作:

    1 准备两台linux pc 我们一般用的是VMware虚礼软件

    2 这两台linux可以互通

    3 linux1 :192.168.2.2 这台为你要连接的服务器

    linux2 :192.168.2.3

    4 防火墙关闭

    5 ssh这个套件一定要安装,不过默认的都是安装好的

    操作步骤

    linux客户机

    [root@localhost~]#ssh-keygen -t rsa

    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:

    c0:25:62:65:c9:24:bd:14:8d:01:dc:50:e0:f9:eb:a7 root@localhost.localdomain

    [root@localhost~]#ls .ssh/

    id_rsa id_rsa.pub

    [root@localhost~]#scp .ssh/id_rsa.pub root@192.168.2.2:/root/

    这句话是说将本机器生成的公钥拷贝到远程你要链接的服务器上,拷贝时要输入密码的。

    到linux服务器上

    [root@localhost~]#mkdir .ssh/

    [root@localhost~]#mv id_rsa.pub .ssh/   -->这里将刚才拷贝过来的文件移致动到.ssh/下

    [root@localhost~]#vim /ect/ssh/sshd_config

    找到:PasswordAuthentication yes 改为 no --->说明不用密码验证,原本是用密码验证的。

    找到:#AuthorizedkeysFile .ssh/authorized_keys 这个很重要过会会用到

    ##:PermitRootLogin no 这句是说是否允许root远程登录 no为不准,yes 为允许

    !!保存退出

    [root@localhost~]#cd .ssh/

    [root@localhost.ssh]#mv id_rsa.pub authorized_keys 现在用到了

    [root@localhost.ssh]#service sshd status -->查看是否以开启

    [root@localhost.ssh]#/etc/init.d/sshd restart -->如果没有开启就执行这句话

    回到客户机上吧:192.168.2.3

    [root@localhost~]#ssh root@192.168.2.2

    这样即可连接了

    如有这个出现则:Enter passphrase for key '/root/.ssh/id_rsa': 输入你刚才为密钥加密的密码就可以了

  • 相关阅读:
    c11---位运算相关
    c10---多文件开发
    C9---include,编译
    c8---递归
    c7---函数
    c6----函数的声明和实现
    c5
    Arm 环境上面libgdiplus的简单安装配置
    批量查找可执行文件目录的简单方法
    Android常用工具类
  • 原文地址:https://www.cnblogs.com/johnnyflute/p/3519067.html
Copyright © 2020-2023  润新知