SSH Server side: A
SSH Port of A: PortA
A's user name: Namea
A's Ip:ipa
SSH Access port: B
User name for B: Nameb
B's IP:IPB
Effect: b accesses a through SSH
1) Confirm that SSH is installed (confirm by restarting)
Service sshd Restart or service ssh restart
If it is possible to restart the instructions if SSH is installed, if the Ssh:unrecognized service instructions are displayed, SSH is not installed correctly
Installing SSH via Apt-get install Openssh-server
2) See if SSH or sshd exists under/etc/init.d/
3) server-side A: Modify the/etc/ssh/sshd_config configuration file
#PermitRootLogin Without-password
Permitrootlogin Yes
Rsaauthentication Yes
Pubkeyauthentication Yes
4) Generate secret key and public key (generated can be skipped)
SSH-KEYGEN-T RSA
Return to the key (ID_RSA) and public key (Id_rsa.pub)
5) Add B access rights
Copy the public key of B to the end of the/root/.ssh/authorized_keys file of a
or by Ssh-copy-id [email protected]
If the SSH port number is not port 22nd, pass
Ssh-copy-id "-p PortA [email protected]"
Once added, you can login without a password.
Can be tested by a native
Add access to B after the test is successful
SSH [email protected]-P PortA
6) Warning:remote HOST identification has CHANGED
This problem may be due to the access of the IP's public key information is different from the known_hosts, the removal of the IP of the known_hosts in the corresponding RSA information can be
7) If the connection port fails, you can use Telnet aip-p PortA to see if the port is open by
sudo ufw enable (enabled)
sudo ufwdisable (disabled)
Firewall to test if the port is blocked due to a firewall
Open or close a port, for example:
sudo ufw allow 22/tcp #允许所有的外部IP访问本机的22/tcp (SSH) port
sudo ufw deny 22/tcp #允许所有的外部IP访问本机的22/tcp (SSH) port
Reference article:
Http://www.linuxidc.com/Linux/2016-12/138259.htm
http://roclinux.cn/?p=2551
http://blog.51cto.com/linuxme/375752
http://blog.csdn.net/universe_hao/article/details/52296811
Ubuntu under SSH password-free login settings