Using Sharpssh telnet host to execute command transfer files under Windows via SSH

Source: Internet
Author: User
Tags sha1 hash
1. What is SSH

SSH is a security protocol based on the application layer and the transport layer. SSH is currently a more reliable protocol for providing security for Telnet sessions and other network services. SSH is the standard configuration for each Linux computer, but SSH is not installed by default in Windows, and SSH-related server software, such as FREESSHD, is required.
2. What SSH can be used to do

SSH can be used to log on to a host, usually in two ways: password logon and public key logon

One: Password login: By the user name and password set in the server to login, every time you need to enter a password to login

Two: Public key logon: Login with a pair of public and private keys, the public key is stored on the client side of the server, a random string is sent to the client at logon, and then the client is encrypted by the private key and then occurs to the server, the server accepts and decrypts with the public key, and then the match is decrypted correctly to verify the login , note that there is a consistent public key name and user name on the service side, which distinguishes the public key of different users, so that each time you can log in directly with the public key to save the cumbersome password.

SSH allows bidirectional file transfer between user server and client 3. Sharpssh and SSH service end freesshd

Sharpssh is a C # implementation of the SSH client component, users can modify the use of changes as needed to meet their own needs, Sharpssh Introduction and Component Download site: http://sharpssh2.codeplex.com/, can also be downloaded here.

Note: In the official website download sharpssh will be due to the host to install Mono Mono.Security.dll reference error, only need to download Mono.Security.dll re reference.

I am in Windows7 VS2012 environment test website Download SHARPSSH Project Upgrade success, the solution is as follows:


There are two items: Examples,sharpssh as the name suggests, examples is using the example, SHARPSSH is the real implementation project, set examples as the startup item, the effect is as follows:


As you can see, the example provides us with 16 feature items, again we need to test remote logins and file transfers, use 13th, and 16 Tests, and also use the 5th item to generate public key pair;


Client SHARPSSH has been implemented, the next in the Windows system will need to install the client, here Select Freesshd as the client, the official website download address: http://www.freesshd.com/?ctt= Download or here: http://download.csdn.net/detail/dangercheng/6804861

Download the next step directly next installation, installation is completed after the operation will prompt you whether to generate key selection is can, and will install Freesshdservice services, choose to close the service;

At this point you can see that the Telnet and SSH services are supported, all closed, and the client server is ready for this step, let's do our login test and file transfer test. 4. Remote Login Execution Command

Mentioned above, there are two ways to login, password login and public key login, first introduction password login bar;

Password login: That is, create a username and password on the server freesshd, and use this password password to log in

First, click Add pop-up Add user interface on FREESSHD, then login to fill in username, authorization select password stored as SHA1 hash then fill in password and repeat password, check the user available services, As shown in the following figure, the user name and password are created with test:


Then we select the SSH entry, the use of the new console engine to remove the check to prevent the noon garbled, as shown:


Select OK to create success and then back to the main interface we open SSH service


As shown in the figure above, the SSH service has been successfully opened, but it may be wrong: the common cause is that the address is already in use, which is the result of port number 22 already in use, and the process of shutting down the port.

Next we run our sharpssh for a login test.

We select item 13th and then enter the remote address I (because the server is 127.0.0.1 on the local computer), then do not select the public key to log in, then enter the password, connect successfully, execute the date command to query the current time:


Now we test the public key login:

Public key login requires a public key to the key pair, we choose the 5th item keygen to generate, named Test (and user name is consistent), Sig type Select DSA, then comment for empty pop-up window input passphrase we do not enter directly select OK, This generates our test's public key private key two files in the Sharpssh bin\debug directory. As shown in figure:


A public key test.pub and private key test two files were generated. The public key file Test.pub is then placed in the Public key folder directory specified by freesshd:


That is, C:\Program files\freesshd\ this directory, and remove the suffix. Pub, then modify the test user's authorization Select public key as shown:


Next Test:


5. Transfer files

First we modify the server-side file location:


The default location for our server is the Sftpfile directory we added below Freesshd, where we put a picture test.jpg, and now we want to upload this image to our Sharpssh Directory page bin\ In the debug directory and renamed to Testclient.jpg:


You can see the speed of the transmission is still very fast 93k0 seconds to complete, interested can try large file transmission, to this about SSH login and file transfer test completed, of course, SSH has many other powerful functions, here can not enumerate the test, have the interest to take a try.

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.