当前位置:网站首页>Putty installation and use

Putty installation and use

2022-06-12 06:58:00 ToLoveToFeel

putty Installation and use

1 install

  • putty Is a windows A handy gadget for connecting to a remote server . Download address : website . Go to the website , Find the following content to download :

 Insert picture description here

  • You can also download the historical version : History version download .

  • You can also download and upload the installation file directly : website . Download after decompression , double-click .msi Just install the file .

  • All the way default during installation , Finally, there will be four more programs , Here's the picture :

 Insert picture description here

  • Where we can open these applications , The default location is :C:\Program Files\PuTTY, This path has been added to the environment variable , Therefore, you can use the .exe As command , The contents of this folder are as follows :

 Insert picture description here

  • Here is a brief description of the next folder 6 individual .exe Role of documents :

    • putty.exe: Remote connection server , Most commonly used ;

    • puttygen.exe: Generate public and private keys , Used for password free login to remote server ;

    • psftp.exe: Used in Local 、 remote server Transfer files between ;

    • pscp.exe: and psftp.exe It works the same , But the order is different , The command is similar to linux Medium scp command ;

    • plink.exe: Commands for executing remote servers locally ;

    • pageant.exe: Used to manage secret keys .

  • Here is how to use the five tools shown in the above picture .

2 Use

2.1 putty.exe

  • This is a putty The most common tools in the suite , The initial interface is as follows :

 Insert picture description here

  • Here, enter the name of the remote server IP Address , And the login port number (SSH The default port number is 22), Click on Open after , You can log in after entering your account and password in the pop-up interface . Here's the picture :

 Insert picture description here

  • Here is a demonstration of logging in to Alibaba cloud server , The user is called wxx, The password you enter will be hidden ( That is, the password we enter will not display ).

  • If you want to log in to multiple servers , We can save it as session, Here's the picture , Saved two session( named :aliyun、django):

 Insert picture description here

  • Input IP Address 、 port 、 And the session name , Save it at last , Here's the picture :

 Insert picture description here


  • You can see that after logging in to the terminal , The font is very small , Therefore, it is necessary to set the font size in the terminal , It is likely that after the setting is completed , The next restart will fail , Here's how to avoid this problem .

  • I have three in all session( Two self created , A default Default Settings), Each needs to be set individually , It can be understood as each session All configurations are independent .

  • Here to set aliyun This session For example , It mainly explains how to set the font size of the terminal , Steps are as follows :

(1) Click on aliyun, And then click Load Button , Here's the picture :

 Insert picture description here

(2) Click... In the menu bar on the left Window->Appearance, And change the font size , Here's the picture :

 Insert picture description here

(3) Click... In the menu bar on the left Session, Then click... On the right Save Button , Here's the picture :

 Insert picture description here

  • Then restart in time putty, about aliyun This session, The settings are all effective . Other settings are similar , Just change the number (2) Step by step . For example, after 2.2 Section .

  • Be careful : hinder psftp、pscp、plink Commands are directed at Default Settings This session operational . This will be mentioned later .

2.2 puttygen.exe

  • Every time we log in to the remote server, we need to enter the user name and password , In particular, enter the password , Very troublesome , This tool is designed to solve this problem .

  • Click on puttygen.exe, The default interface is as follows :

 Insert picture description here

  • Click on Generate Button , The mouse moves freely in the blank space , Generate public and private keys , The demonstration is as follows :

 Insert picture description here

  • The final generated interface here is as follows :

 Insert picture description here

  • You can see that the encryption algorithm uses RSA Algorithm , For the explanation of the algorithm, please refer to :RSA Public key encryption algorithm . The algorithm generates Public key and Private key , The public key can be made public , The private key cannot be exposed .

  • You need to upload the public key to the server , Save the private key locally . Click on the image above Save private key, If a warning box pops up , Click Yes to , Then name the saved private key and save it . The following figure shows the private key to be saved , And public key ( Copy directly to txt Then you can ):

 Insert picture description here

  • The location of my public key and private key in the computer is as follows ( The private key is generated by clicking the button , The public key is new txt file , And then copy the content into ):

 Insert picture description here


  • Then you can configure password free login , First log in to the server with your user name and password , establish .ssh Folder , Create in folder authorized_keys file , This file is used to store the public key generated before ( You can store multiple public keys ), The order is as follows :
mkdir .ssh
cd .ssh
touch authorized_keys
  • Then copy the previously generated public key to the file authorized_keys in .

  • After that, you need to configure the password free login session, Set only the (2) Step operation is different , Here's the picture :

 Insert picture description here

  • Remember to save the settings later .

  • Then log in , You can find , Just enter the user name to log in to the remote server , Here's the picture :

 Insert picture description here

2.3 psftp.exe

  • Used to transfer files between local and server , Can be in cmd Enter the command directly in the window psftp, You need to enter a user name 、 Password to log in . If in putty Password free login is configured in , You only need to enter the user name .

  • Be careful : The default remote server connected here is putty in Default Settings The corresponding server in .

  • The interface entered by using this command is as follows , Can pass help View the commands provided :

 Insert picture description here

  • Common commands :
pwd			#  Display the current directory in the remote server 
cd			#  Switch directories on the remote server 
ls			#  Show files in the remote server folder 

lpwd		#  Display the current directory in the local 
lcd			#  Switch directories locally 
!dir		#  Show files in local folder 

put			#  Upload local file to server 
get			#  Download the server file to the local 
  • file 、 Transfer of folders :

(1) Upload local files to the server (D:\psftp\local_file.txt --> /home/wxx/):

put d:\psftp\local_file.txt

(2) Download files from the remote server to the local (/home/wxx/.bashrc --> D:\psftp\

lcd d:\psftp		#  Local directory switching 
get .bashrc

(3) Upload the local folder to the server (D:\psftp\local_test\ --> /home/wxx/):

put -r d:\psftp\local_test

(4) Download the folder on the remote server to the local (/home/wxx/.ssh/ --> D:\psftp\

lcd d:\psftp		#  Local directory switching 
get -r .ssh

2.4 pscp.exe

  • and psftp The functions are basically the same , For file transfer between local and remote .

  • Another server is used here django demonstration , This server is through docker Built , Set up in aliyun Server , Port mapping ,aliyun Upper 20000 The port is mapped to docker Inside 22 port .

  • If no port is specified , Then the port is putty in Default Settings This session Corresponding port .

  • file 、 Transfer of folders ( Directly in cmd Enter the following command in ):

(1) Upload local files to the server (D:\psftp\local_file.txt --> /home/acs/):

pscp -P 20000 d:\psftp\local_file.txt [email protected]:/home/acs/

(2) Download files from the remote server to the local (/home/acs/.bashrc --> D:\psftp\

pscp -P 20000 [email protected]:/home/acs/.bashrc d:\psftp\

(3) Upload the local folder to the server (D:\psftp\local_test\ --> /home/acs/):

pscp -P 20000 -r d:\psftp\local_test [email protected]:/home/acs/

(4) Download the folder on the remote server to the local (/home/acs/.ssh/ --> D:\psftp\

pscp -P 20000 -r [email protected]:/home/acs/.ssh d:\psftp\

2.5 plink.exe

  • Commands for executing remote servers locally , Directly in cmd It can be executed in .

  • If no port is specified , Then the port is putty in Default Settings This session Corresponding port .

  • Execute locally aliyun Command on :

plink -P 22 [email protected] "ls -al"
  • Execute locally django Command on :
plink -P 20000 [email protected] "ls -al"
原网站

版权声明
本文为[ToLoveToFeel]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010604278209.html