Connect the Linux Server By Private Key in WinSCP Software
Introduction of WinSCP
WinSCP (Windows Secure Copy) is a free and open-source graphical SFTP (SSH File Transfer Protocol), SCP (Secure Copy Protocol), FTP (File Transfer Protocol), and WebDAV (Web Distributed Authoring and Versioning) client for the Windows operating system. It allows users to securely transfer files between a local computer and a remote computer.
User Account Generate
Sometimes, the linux server only uses public key to generate user account instead of IP address and password so we need to generate the private key first.
Generate the Private Key
Open the git
terminal and run the following command:
1 | ssh-keygen -t rsa |
After running, we can get the id_rsa
file in the .ssh
directory and the id_rsa.pub
file in the same directory.
Add the Public Key to the Server
Once got the public key, we can just use it to create a new user account on the server. The following command is used to add the public key to the server.
1 | ssh-copy-id -i ~/.ssh/id_rsa.pub zhli@cwfang.tpddns.cn |
WinSCP Configuration
Firstly, we need to open the WinSCP and click the ‘Tools’ button to
Run PuTTYgen
:Then, click
Load
button to find previously generated private key file(id_rsa
):
There when we choose the key file, it’s necessary to switch target file type to All Files(*.*)
for matching.
- After that, just wait for processing and finally we can
Save private key
in the format of.ppk
:
.ppk
format is a need for WinSCP to obtain the local computer’s authorization to the linux server.
- Config the private key in WinSCP globally
InAdvanced
module we can find theAuthentication
interface used for SSH connection. In this module,Private key file
is used to select the private key file ending with.ppk
format.
The generated .ppk
file is just our private key file and it is used to match the public key file in the linux server. In this way, we can just use WinSCP to upload the file to the linux server.
WinSCP Connection
Finishing above steps, it’s just time to use WinSCP to connect to the linux server.
- In WinSCP, we can find the
Session
interface to set up the connection. - In
Session
interface, we can set up the connection information, including the server domain(Host name), username, password, port.
Connect the Linux Server By Private Key in WinSCP Software