1. Overview
Traditional Telnet (telnet,rlogin) is not secure, they transmit passwords and data in plaintext on the network, SSH is secure, and OpenSSH provides two levels of authentication.
(1) Password-based security authentication: Know the server's account password can be telnet, password and data in the transmission process will be encrypted.
(2) Key-based Security authentication: At this point you need to create a pair of keys, the public key to the remote server in its own host directory, and the private key is saved by themselves.
2. Software Installation
sudo apt-cache policy openssh-client openssh-server Check to see if the software is installed
Server: sudo apt-get install Openssh-server
Client: sudo apt-get install openssh-client (ubuntu10.10 later versions are already installed)
The package also carries some other SSH tools, such as Ssh-keygen used to generate private/public key pairs, SCP can be used to remotely copy files via SSH, STFP can be implemented FTP transfer files
3. Configuration files
[Email protected]:/etc/ssh$ ls-Ltotal148-rw-r--r--1Root root125749 .- the- the Geneva: theModuli//diffie-helllman key file for SSH server-rw-r--r--1Root root1669 .- the- the Geneva: theSsh_config//SSH Client configuration file-rw-r--r--1Root root2453 .-Geneva- the -: theSshd_config//SSH server-side configuration file-RW-------1Root root672 .-Geneva- the -: theSsh_host_dsa_key//SSH server-side DSA algorithm private key-rw-r--r--1Root root613 .-Geneva- the -: theSsh_host_dsa_key.pub//SSH server RSA public key-RW-------1Root root1675 .-Geneva- the -: theSsh_host_rsa_key//SSH server RSA algorithm private key-rw-r--r--1Root root405 .-Geneva- the -: theSSH_HOST_RSA_KEY.PUB/SSH Server RSA algorithm public key
4. Common commands
sudo/etc/init.d/ssh Start|stop|restart|status(one of them)
5. Password-based authentication
ssh 192.168. 0.143/Host name (server IP 192.168. 0.143)
There is a lot of information when you first log on to the server, because SSH does not recognize the host, and when you enter yes it will write the information to the ~/.ssh/known_hosts file, which will not appear the next time you log in.
6. Key-based authentication
Copy the public key to the remote server;
When the client logs on to the server, it makes a request to the server and authenticates with the private key;
After the server receives the request, it looks for the public key for authentication.
(1) Generate key ssh-keygen-t RSA/DSA (default RSA)
Generate private key:~/.ssh/id_rsa, public key ~/.ssh/id_rsa.pub,
(2) SCP id_rsa.pub 192.168. 0.143:. Ssh/authorized_keys and ensure that the permissions are 644.
(3) ssh 192.168. 0.143 If the private key password is set during the Ssh-keygen process, a private key password is required during the logon process. Otherwise, the direct login is complete.
7.SCP Simple to use
SCP ip1:file1 ip2:file2
The first parameter is the source file, the second target file, and the IP or hostname can be omitted when the parameter is an SSH login to the host. When the two parameter is the IP of two remote hosts, the file transfer between the two remote hosts can be implemented.
For example scp/home/zone/1. SH 192.168. 0.143:/home/erpang will download the 1.sh from the server to the Erpang directory of the 143 host.
Original link: http://www.cnblogs.com/xdzone/archive/2011/03/09/1978327.html
Ubuntu client telnet to Ubuntu server via SSH