
我们在前一篇文章中看到 它是什么和如何用 SSH 连接. A 协议 我们可以藉以访问计算机 远程 通过命令控制台或 终端, 让使用它的好像我们身体面对面.
现在我们要显示 五 的的 基本命令, 控制台或终端, 经常用制作任何一种时 连接, 或通过连接一次 SSH.
1. 如何知道你正在使用的 SSH 客户端的版本
有时可能有必要 标识 到 SSH 客户端 当前运行的数目 版本 相应的, 这可以从以下命令获取:
1 2 3 | (local) $ ssh -V OpenSSH_7.3p1, LibreSSL 2.4.1 |
2. 如何使用您的个人计算机或远程计算机登录
的 第一次 你连接到远程计算机, 将显示 消息 在这不一直能够建立 真实性 的的 远程计算机, 将向您展示 RSA 密钥 和会问你是否你想继续:
1 2 3 4 5 | (local) $ ssh root@dominio.com The authenticity of host 'dominio.com (162.XXX.XXX.XXX)' can't be established. RSA key fingerprint is SHA256:lkYwsVbRtSp6d0ljj49p5oU2/LlEPcMrMGtVHd5M/R0. Are you sure you want to continue connecting (yes/no)? yes |
如果您键入 ‘是的‘ o ‘如果‘, 根据所使用的语言来显示它你, 然后按 介绍, 这 将保存信息 在文件中你 本地 PC 为将来的连接.
1 2 3 4 | Warning: Permanently added 'dominio.com,162.XXX.XXX.XXX' (RSA) to the list of known hosts. root@dominio.com's password: (remoto) [root@dominio ~]# |
的 第二次 问你仅建立连接 密码, 由于远程计算机的关键已经被保存在列表中 已知的主机 SSH 客户端.
1 2 3 4 | (local) $ ssh root@dominio.com root@dominio.com's password: (remoto) [root@dominio ~]# |
这是真正除非的某些方面 远程机更改, 作为一个 升级或重新安装 SSH 远程服务器, 或任何 恶意活动 由第三方, 作为 拦截的攻击, 因此,将显示以下消息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is SHA256:hJ3rufgbBEBzVJ3Ua487BR2m1m30RKzogZlhRtdFf24. Please contact your system administrator. Add correct host key in /Users/XXXXXXXX/.ssh/known_hosts to get rid of this message. Offending RSA key in /Users/XXXXXXXX/.ssh/known_hosts:2 RSA host key for dominio.com has changed and you have requested strict checking. Host key verification failed. (local) $ |
3. 如何传输文件和从远程主机
当你与工作 SSH 客户端 这是合乎逻辑的需要 发送和获取文件 并从远程计算机. 要做到这一点, 我们使用以下命令:
为航运:
1 2 3 4 5 6 | //Enviar archivos desde nuestro ordenador al equipo remoto (local)$ scp archivoLocal.txt root@dominio.com:/home/archivoRemoto.txt root@dominio.com's password: archivoLocal.txt 100% 71KB 123.0KB/s 00:00 |
为获取或接获:
1 2 3 4 5 6 | //Obtener archivos desde el equipo remoto a nuestro ordenador (local)$ scp root@dominio.com:/home/archivoRemoto.txt archivoLocal.txt root@dominio.com's password: archivoLocal.txt 100% 71KB 168.0KB/s 00:00 |
在这两种情况, 该命令将问 密码, 将一次介绍 上升或下降的文件 在问题, 文件夹或目录说明.
4. 如何执行清除连接以解决可能出现的问题
有时它有必要看看不同 调试消息 它可以发生在连接, 目的 修复 可能 问题 用 SSH. 要做到这一点, 我们只是有的 添加 选项 -v 我们连接参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 | (local) $ ssh -v root@dominio.com OpenSSH_7.3p1, LibreSSL 2.4.1 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 20: Applying options for * debug1: Connecting to dominio.com [162.XXX.XXX.XXX] port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /Users/XXXXXXXX/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/XXXXXXXX/.ssh/id_rsa-cert type -1 ... ... |
5. 如何在本地计算机和远程计算机之间切换
一次 登录 与 远程计算机, 如果你需要 返回 您当地的团队, 不需要 关闭 SSH 会话后重新打开它并继续远程处理, 但是你可以简单地 交流 之间 会话 离开与 SSH 客户端作为一个过程的连接中 背景.
要做到这一点, 一旦你 连接 通过 SSH 到远程计算机, 和你想替换与您的本地计算机, 按下键 ~ 然后 CTRL + z. 会给你这样的事情.
1 2 3 4 | (remoto) [root@dominio ~]# ~^Z [suspend ssh] [1]+ Stopped ssh root@dominio.com (local) $ |
如果想要到现在 返回 到你 远程计算机, 只需运行 命令 以下:
1 2 3 4 5 | (local) $ fg %1 ssh root@dominio.com (remoto) [root@dominio ~]# |
有了这些 五个命令, 您可以从运行 控制台或终端, 你可以做更多 容易 你让与的连接 SSH 协议 到远程计算机, 可以使 简单文件共享 和一个人 两届会议之间交替 你不需要关闭这些窗口以使用两个, 除了显示的可能性.
