Modify the SSH port and use the key to log on to Ubuntu

Source: Internet
Author: User
Tags ssh port ssh server
1. use SecureCRT to create the private key and public key. secureCRT: QuickConnect-& gt; Authentiation-& gt; PublicKey-& gt; Properties-& gt; CreateIdentityFile-& gt; DSA/RSA-& gt; SetPassphrase-& gt; done generates two files in the specified directory at this time, for example, private key I

1. Use SecureCRT to create the 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 are generated in the specified directory, such as the Private Key Identity and Public Key Identity. pub.

2. Create a new user

# Useradd subsir-m # su subsir // switch to the subsir user. The following operations must be performed using the subsir account, and subsir must have the permission.

3. Create the. ssh folder in the/home/roger directory and change the permission.

# mkdir /home/subsir/.ssh# chmod 700 /home/subsir/.ssh

4. Upload the Public Key Identity. pub to the linux server and convert the public key in the SSH2 compatible format to the Openssh compatible format.

# ssh-keygen -i -f Identity.pub >> /home/subsir/.ssh/authorized_keys# chmod 600 /home/subsir/.ssh/authorized_keys

5. Set the logon mode to PublicKey in SecureCRT, and select the created Identity file as the private key.

6. Restart the SSH server on the Ubuntu server.

#sudo /etc/init.d/ssh restart

7. Because you have set a key to log on, you can remove the original password.

# vi /etc/ssh/sshd_config

# If you want to modify the Port:
# Change port 22 to port number

Protocol 2/Only SSH2 is allowed
PubkeyAuthentication yes/* enable PublicKey Authentication
PasswordAuthentication no/* password verification prohibited Login

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.