Setting method of secure CRT key login Linux SSH

Time:2021-10-17

1、 First create the key with SecureCRT

1. Use SecureCRT to create private key and public key

  SecureCRT quick Connect-> Authentiation -> Public Key -> Properties ->Create Identity File -> DSA/RSA -> Set Passphrase -> Done

At this time, two files will be generated in the specified directory, for example, the private key my_ RSA and my_ rsa.pub

2. Create the. SSH directory on the Linux server. Generally, this directory already exists

  # mkdir /root/.ssh

  # chmod 700 /root/.ssh

3. Set the public key to my_ Rsa.pub is transmitted to the Linux server to convert the public key in SSH2 compatible format into openssh compatible format

  # ssh-keygen -i -f Identity.pub >> /root/.ssh/authorized_keys2

  # chmod 600 /root/.ssh/authorized_keys2

4. Set the login mode to publickey in SecureCRT, and select the newly created my_ RSA file as private key

5. Restart the ssh server on the Linux server

#service sshd restart or / etc / init.d/ssh restart

6. Since the key login has been set, the original password login can be completely removed

  $ sudo vim /etc/ssh/sshd_config

Protocol 2 / SSH2 only allowed

Publickeyauthentication yes / * enable publickey authentication

  AuthorizedKeysFile .ssh/authorized_ Keys2 / * publickey file path

Passwordauthentication no / * disable password authentication login

PS: the above steps use the key pair generated by SecureCRT for login verification. In fact, you can also use the key generated by SSH keygen command on the server. Similarly, after generating the key pair, convert the format to the SSH2 format used by SecureCRT

Note: the conversion key format in step 3 is easy to be ignored. Please pay more attention to this.

2、 Share the created private key

Because the private key created by SecureCRT is different from the private key format used by winscp, it needs to be converted

  securecrt>>tools>>Convert Private Key to OpenSSH Format …

Save the key pair in openssh format, then run puttygen > > conversions > > import key in winscp package, select the private key just converted, enter key passphrase, select Save private key and save it as a file in PPK format

3、 Solve the Chinese garbled code problem of winscp

Check the advanced option on the winscp startup screen, and then turn off the option that the server does not use UTF-8 encoding in the SFTP setting.