Change the & amp; private key public key configuration for SSH ports in Linux

Source: Internet
Author: User
Tags ssh port

Ps: how to change the SSH port in Ubuntu

(1) modify the SSH port
1.1 Modify/etc/ssh/sshd_config

Port 22 // The default ssh Port is 22.
Port 25680 // change the Port number to 25680
Ps: when changing a service port, it is best not to delete the original port number to avoid affecting others' use. Add a port first. After the test is passed, delete the original port number!
1.2 restart the ssh service. The modified port takes effect.
Sudo/etc/init. d/ssh restart
1.3 run the netstat-an command to check whether the command is correct.
You can also log on using similar tools such as SecureCRT to check whether it can be added to the port login through the newly added. If you can log on, delete the original port number 22.
(2) configure the private key and Public Key
2.1 ssh-keygen-t dsa-p'-f ~ /. Ssh/id_dsa
Cat ~ /. Ssh/id_dsa.pub> ~ /. Ssh/authorized_keys
2.2 test whether the configuration is successful
Ssh localhost
Ps: if the test fails, you can try to modify the permission of the relevant directory and try again.
Chmod 700 ~ /. Ssh
Chmod 600 ~ /. Ssh/authorized_keys

2.3 copy the public key file to the remote server
1. Method 1:
Cat ~ /. Ssh/id_dsa.pub | ssh remote user name @ Remote Server ip-p port number 'cat-> ~ /. Ssh/authorized_keys'
2. Method 2:
Local execution:
Scp-p port number ~ /. Ssh/id_dsa.pub remote user name @ ip:/home/remote user name/
Log on to the remote server and run the following command:
Cat id_dsa.pub >> ~ /. Ssh/authorized_keys
Ps: if the test fails, you need to change the authorized_keys permission of the file on the remote server IP address (permission setting is very important because security settings are not secure, so that we cannot use the RSA function)

Idea
1. Can I log on directly through ssh without entering the port number after changing the port number? Ps: it seems no!

Configure SSH password-less logon in CentOS

Implement SSH password-less authentication login in Linux

How to configure SSH for Ubuntu and CentOS to enable password-less 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.