用户工具

站点工具


atk:ssh_keys

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
atk:ssh_keys [2019/06/30 16:36] – [Linux 和 OS X] xie.congweiatk:ssh_keys [2019/06/30 16:47] (当前版本) – [参考] xie.congwei
行 63: 行 63:
 ===== 将公共秘钥添加到远程集群已授权的 SSH 秘钥 ===== ===== 将公共秘钥添加到远程集群已授权的 SSH 秘钥 =====
  
 +
 +下一步,您需要将您的公共 SSH 秘钥添加到远程集群已授权秘钥的清单上。
 +
 +<WRAP center important 100%>
 +=== 注意 ===
 +您可能需要集群的管理员为您执行此操作。无论如何,下面我们将展示如何在您有权访问的情况下执行此操作。
 +</WRAP>
  
 ==== Linux 和 OS X ==== ==== Linux 和 OS X ====
  
 +使用 ''ssh-copy-id'' 命令:
  
 +<code python>  
 +ssh-copy-id -i /home/user/.quantumatk/QuantumATK_rsa username@HOST.CLUSTER.EDU
 +</code>
 +
 +在出现提示时输入您的密码。您的公共秘钥现在应该被添加到集群的 ''/home/user/.ssh/authorized_keys'' 文件里。
 ==== Windows ==== ==== Windows ====
  
 +您需要登录集群,手动添加秘钥。
 +
 +打开您电脑上的 PuTTY,输入远程的主机名称并点击 Open。
 +
 +{{ :atk:putty-20190630.png?500 |}}
 +
 +
 + 图 21 用合适的主机名称替代 HOST.CLUSTER.EDU。
 +
 +  * 将您公共秘钥的内容(扩展名 ''.pub'' 的那个)添加到文件 ''/home/user/.ssh/authorized_keys'',然后保存。
 +  * 退出远程集群,进行下一部分,测试设置。
 ===== 测试无密码的 SSH 连接 ===== ===== 测试无密码的 SSH 连接 =====
  
 +===== 测试无密码的 SSH 连接 =====
  
-===== 参考 =====+我们在这里提供了一个 QuantumATK 脚本,它将尝试建立与远程集群的连接,并报告连接是否成功建立。
  
 +  * 下载脚本 [[https://docs.quantumwise.com/_downloads/ssh_test.py|↓ ssh_test.py]],在第 7 行到第 9 行编辑连接设置(//key_dir//、//hostname// 和 //username//)。
 +
 +<code python>  
 +1    from NL.ComputerScienceUtilities.SSHConnection import SSHConnection
 +2    import os
 +3    
 +4    # -------------------------------------- #
 +5    # Edit only these 3 settings
 +6    # -------------------------------------- #
 +7    key_dir  = 'path_to_SSH_keys'
 +8    hostname = 'HOST.CLUSTER.EDU'
 +9    username = 'my_user_name'
 +10   
 +11   # -------------------------------------- #
 +12   port = 22
 +13   ok = os.path.isdir(key_dir)
 +14   if ok:
 +15       print("Sucessfully found local dir with SSH keys.")
 +16       con = SSHConnection(hostname, port, username, key_dir)
 +17       con.connect()
 +18       ok = con.isConnected()
 +19       
 +20       if ok:
 +21           print("Connection succesful.")
 +22   else:
 +23       print("Error: Could not find local dir with SSH keys.")
 +24   # -------------------------------------- #
 +</code>
 +
 +  * 从命令行执行:
 +
 +<code python>  
 +$ atkpython ssh_test.py
 +</code>
 +
 +  * 如果测试通过,则会打印出以下行:
 +<code python>  
 +Successfully found local dir with SSH keys.
 +Connection successful.
 +</code>
 +
 +
 +<WRAP center tip 100%>
 +=== 提示 ===
 +您现在应该已准备好使用 QuantumATK 作业管理器在远程集群上运行的 QuantumATK 作业,请参阅教程 [[https://docs.quantumwise.com/tutorials/job_manager_remote/job_manager_remote.html#job-manager-remote|Job Manager for remote execution of QuantumATK scripts]]。
 +</WRAP>
 +
 +===== 参考 =====
  
 +  * 英文原文:https://docs.quantumwise.com/tutorials/ssh_keys/ssh_keys.html
  
  
  
  
atk/ssh_keys.1561883766.txt.gz · 最后更改: 2019/06/30 16:36 由 xie.congwei

© 2014-2022 费米科技(京ICP备14023855号