zoukankan      html  css  js  c++  java
  • Appendix F. Tips and tricks for SSH/PuTTY

    Appendix F. Tips and tricks for SSH/PuTTY

    需要先去putty官网下载putty客户端,TortoiseGit自带的不行,自带的,只能生成。

    How to download and install PuTTY

    How to open a PuTTY session, and exit a session

    Table of Contents

    F.1. Introduction
    F.1.1. How to use sessions
    F.2. FAQ and examples section
    F.2.1. How to use a default key for all SSH connections
    F.2.2. How to connect to a SSH server on a different port
    F.2.2.1. All connections to a server should use the different port
    F.2.2.2. One special connection should use a different port
    F.2.3. How to use two different SSH keys for the same user on the same host

    F.1. Introduction

    PuTTY comes with a great session management, where you can save attributes of connections (e.g. SSH key, username, port). This page describes how to make use of it - partly in form of a FAQ.

    For this to work, you need the PuTTY.exe-application.

    F.1.1. How to use sessions

    One special "session" is the Default Settings session, where you can set default values for all new connections (e.g. a key, a default username, enable compression, force SSH version 2 or change the default port and so on).

    You can also save settings for (single) SSH connections as sessions. Take one server where the SSH server only listens on a different port, then you can set up all settings and save it to e.g. SERVERNAME. Now you can access this saved settings by starting PuTTY and double clicking SERVERNAME in the saved sessions list OR, when using TortoiseGit, plink or other putty applications, the entered host name/destination (e.g. git@SERVERNAME:/test.git) will be matched against the saved sessions list and if found, the settings of the saved session are used.

    Many people like to use Pageant for storing all their keys. Because a PuTTY session is capable of storing a key, you don't always need Pageant. But imagine you want to store different keys for several different servers; in that case you would have to edit the PuTTY session over and over again, depending on the server you are trying to connect with. In this situation Pageant makes perfect sense, because when PuTTY, Plink, TortoiseGitPlink or any other PuTTY-based tool is trying to connect to an SSH server, it checks all private keys that Pageant holds to initiate the connection.

    F.2. FAQ and examples section

    This section is based on the descriptions above and will bring some examples for the usage with TortoiseGit (and plink).

    The examples assume that you want to clone git@example.com:/test.git.

    F.2.1. How to use a default key for all SSH connections

    Start PuTTY, go to Connection->SSH->Auth and select your key. Then go to Session, select Default Settings and hit Save.

    Now PuTTY (TortoiseGit and plink) will try to use this key for all new connections (no need to configure it in TortoiseGit). If the PuTTY agent is running, putty and plink try to use an already loaded key, but will ask for the password themselves (as a fallback).

    F.2.2. How to connect to a SSH server on a different port

    F.2.2.1. All connections to a server should use the different port

    Start PuTTY, fill in the remote host name (example.com here) in the Host Name-field and into the Saved Sessions field. Change the port number to the number you need and click on Save. Now, when TortoiseGit/plink uses this host name and the port is automatically loaded from the session.

    F.2.2.2. One special connection should use a different port

    Start PuTTY, fill in the remote host name (example.com here) in the Host Name-field and put the remote host name followed by e.g. a number into the Saved Sessions field (e.g. example.com1 or whatever you like). Change the port number to the number you need and click on Save.

    Now, when you want to use this saved session use example.com1 as the remote host name: Clone git@example.com1:/test.git. Plink detects that this is a saved session and loads the stored remote host name and port from the session.

    You can create several sessions for a server with different session names, but make sure you do not use the remote host name (example.com here) as the exact session name, otherwise these settings will be the default ones if you try to connect to the server (example.com).

    F.2.3. How to use two different SSH keys for the same user on the same host

    Start PuTTY, fill in the remote host name (example.com here) in the Host Name-field and put the remote host name followed by e.g. a number into the Saved Sessions field (e.g. example.com1 or whatever you like). Go to Connection->SSH->Auth and select the key which should be used for this connection. Now go back to Session and hit Save.

    Now, when you want to use this saved session use example.com1 as the remote host name: Clone git@example.com1:/test.git. Plink detects that this is a saved session and loads the stored remote host name and SSH key from the session.

  • 相关阅读:
    从开发者的角度分析iOS应如何省电
    微信逆向工程之远程操作Mac
    [UIApplication sharedApplication].idleTimerDisabled=YES;不自动锁屏 [UIApplication sharedApplication].idleTimerDisabled=NO;自动锁屏
    [软件逆向]实战Mac系统下的软件分析+Mac QQ和微信的防撤回
    iOS的坑:ERRORITMS-90096: "Your binary is not optimized for iPhone 5
    iOS下简单实现滑动导航条
    遇到线程阻塞,主线程死亡的问题,线程与信号量的使用
    断点续传和分块上传
    关于Instruments-Leaks工具的归纳总结
    valueForKeyPath常用用法
  • 原文地址:https://www.cnblogs.com/chucklu/p/15433082.html
Copyright © 2011-2022 走看看