Install cygwin and enable ssh

The packages that must be installed when installing cygwin are:

wget 

make

yasm

lynx

openssh

libopenssl

 

The general steps to open ssh in cygwin

1. Open the cygwin console: enter ssh-host-config 
2. Prompt that the installation is successful. Enter net start sshd to start the ssh service
3. Use SecureCRT to link: the username and password are the username and password for logging in to the Windows system

After starting cygwin as administrator

$ ssh-host-config


*** Info: Generating missing SSH host keys
*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
*** Info: Creating default /etc/ssh_config file
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
*** Info: Creating default /etc/sshd_config file


*** Info: StrictModes is set to 'yes' by default.
*** Info: This is the recommended setting, but it requires that the POSIX
*** Info: permissions of the user's home directory, the user's .ssh
*** Info: directory, and the user's ssh key files are tight so that
*** Info: only the user has write permissions.
*** Info: On the other hand, StrictModes don't work well with default
*** Info: Windows permissions of a home directory mounted with the
*** Info: 'noacl' option, and they don't work at all if the home
*** Info: directory is on a FAT or FAT32 partition.
*** Query: Should StrictModes be used? (yes/no) no
*** Info: Updating /etc/sshd_config file


*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes
*** Query: Enter the value of CYGWIN for the daemon: [] ntsec
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.  You need to have or to create a privileged
*** Info: account.  This script will help you do so.


*** Info: It's not possible to use the LocalSystem account for services
*** Info: that can change the user id without an explicit password
*** Info: (such as passwordless logins [e.g. public key authentication]
*** Info: via sshd) when having to create the user token from scratch.
*** Info: For more information on this requirement, see
*** Info: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1


*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless such an account
*** Info: already exists). This account is then used to run these special
*** Info: servers.


*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.


*** Info: No privileged account could be found.


*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'LINYANG\cyg_server' (Cygwin name:                      'linyang+cyg_server')? (yes/no) yes
*** Info: Please enter a password for new user linyang+cyg_server.  Please be su                     re
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.

The entered user name or password must comply with the user name or password policy of the computer (especially the computer with restricted rights in the company)
*** Query: Please enter the password:
*** Query: Reenter:


*** Info: User 'linyang +cyg_server' has been created with password 'XXXXXXXXX'.
*** Info: If you change the password, please remember also to change the
*** Info: password for the installed services which use (or will soon use)
*** Info: the 'linyang+cyg_server' account.




*** Info: The sshd service has been installed under the 'linyang+cyg_server'
*** Info: account. To start the service now, call `net start sshd' or
** * Info: `cygrunsrv -S sshd'. Otherwise, it will start automatically
*** Info: after the next reboot.


*** Info: Host configuration finished. Have fun! (Indicates that the configuration is successful)

2 Start the sshd service
$ net start sshd

3 Create a new ssh2 session in secureCRT

hostname写127.0.0.1

port write 22

username writes the login user name of windows, not the previously configured cyg_server

Then a New Host Key dialog box will pop up, click Accept & Save and a window will pop up, enter the current Windows login user name and password.

 

 





 

Install cygwin under win7 and solve the configuration problem

 

1 ssh-host-config reconfigure

If the initial configuration is wrong, most of the Internet recommends deleting it and reinstalling it. However, once cygwin is installed, it is difficult to completely uninstall it. You only need to stop the ssh service and execute this command again, and then overwrite the previous one.

Steps: 1.sc delete sshd

             2. The system restarts, and then the configuration is ok

 

 

 

2 After cygwin is successfully installed, connect to ssh localhost, and it keeps appearing

The error of cygwin Connection closed by ::1 took a lot of time to find, and finally solved it. The original text is as follows:

 

See an official mail question and answer of cygwin on google. See Installing the Cygwin SSH daemon. The key to the problem is a special permission problem. The sshd service running under the SYSTEM account needs to have the privilege to change the user id (about permissions, it has been said very much in cygwin's /usr/share/doc/Cygwin/openssh.README To be clear: 2003 Server has a funny new feature. When starting services under SYSTEM account, these services have nearly all user rights which SYSTEM holds...except for the "Create a token object" right, which is needed to allow public key authentication :-( ). So the event log will have seteuid errors.

As for the solution, let cygwin help you create two special users sshd and cyg_server, where the sshd service runs under the cyg_server user, and cyg_server has the corresponding permissions (also explained in /usr/share/doc/Cygwin/openssh.README) .

***** The key is to create both users.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325069778&siteId=291194637