Use Cygwin/mintty instead of SecureCRT

Source: Internet
Author: User
Tags unix domain socket openssh server

Cygwin is a MS-Windows program that provides a POSIX virtual environment, including but not limited to: posix c api, shell and most famous command line programs.

With the free combination of various gadgets, it can replace the SSH remote logon GUI tool SecureCRT.

Principle:

MS-Windows (win)-jumper-target machine
  • Start openssh server on the pedal
  • Run autossh on win and create a persistent TCP connection between win and jumper to implement the SOCKS5 Proxy
  • Use openssh to connect to the target machine through jumper on win

Procedure

Use cygwin setup.exe to install the following package

net - nc - openssh - ssheditors - vim

Take a user named "bot" as an example to configure the home Directory

ln -s /cygdrive/c/Users/bot /home/mkdir -p ~/bin

Ssh client configuration ~ /. Ssh/config

GSSAPIAuthentication noConnectTimeout 5KeepAlive yesServerAliveInterval 60Compression yesCompressionLevel 5ForwardAgent yesHost from="*.exmaple.com"  User bot  Port 22  ForwardAgent yes  ProxyCommand /bin/nc -x 127.0.0.1:7070 %h %p

When you use ssh to connect a host that ends with exmaple.com as the domain name suffix, it will be connected through the SOCKS5 Proxy 127.0.0.1: 7070.

Configure bash ~ /. Bash_profile

...export PATH=$PATH:$HOME/binbash ~/bin/auto-start-ssh-agent.shsource ~/bin/auto-config-ssh-agent-env.sh

Compile and implement the SOCKS5 Proxy script ~ // Bin/start-jumper-daemon.sh

#! /Usr/bin/env bashautossh-M20000-f-C-D 7070-N-q-A-p 22 Jump Server user @ jump Server IP Address

Execute this script to start two background processes. One process creates a persistent TCP connection between the Windows server and the stepping stone server, and the other monitors. If an error occurs, the system automatically reconnects. Generally, you can run the command once after each boot.

Ssh-agent configuration ~ // Bin/auto-start-ssh-agent.sh

#!/usr/bin/env bashSSH_AUTH_SOCK_DEFAULT=/tmp/ssh-agent.sockif ps aux | grep ssh-agent > /dev/null; then  :else  rm $SSH_AUTH_SOCK_DEFAULT > /dev/null  ssh-agent -a $SSH_AUTH_SOCK_DEFAULTfisource ~/bin/auto-config-ssh-agent-env.shssh-add -L > /dev/null || ssh-add

Ssh-agent configuration II ~ // Bin/auto-config-ssh-agent-env.sh

#!/usr/bin/env bashexport SSH_AUTH_SOCK=/tmp/ssh-agent.sockexport SSH_AGENT_PID=`ps aux |grep ssh-agent |awk '{print $1}'`

Description

  • After the ssh-agent is startedSSH_AUTH_SOCKAndSSH_AGENT_PIDTwo Environment Variables
  • Ssh pass detectionSSH_AUTH_SOCKAndSSH_AGENT_PIDTwo environment variables are used to determine whether there is an ssh-agent background process. If there is an ssh-agent background process, use ssh-agent for automatic authentication. Otherwise, the user is prompted to enter the password.
  • The environment variables set after the ssh-agent is started only exist in the current mintty window session, and the newly started window does not inherit or automatically detect
  • Auto-config-ssh-agent-env.sh through hard-coded ssh-agent unix domain socket path, realize dynamic automatic setting environment variable

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.