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