1. Run the following command to install sshUbuntu: $ sudoapt-getinstallopenssh-serveropenssh-client $ sudoapt-getinstallopenssh-serveropenssh-clientCentOS: $ sudoyuminstallopenssh-serveropenssh-
1. Install ssh
Run the following command in Ubuntu:
- $ Sudo apt-get install openssh-server openssh-client
$sudo apt-get install openssh-server openssh-client
CentOS command:
- $ Sudo yum install openssh-server openssh-client
$sudo yum install openssh-server openssh-client
Run the following command to start ssh:
- $ Sudo service sshd start
$sudo service sshd start
2. Configure SSH login without a password
The configuration in Ubuntu is as follows:
- $ Ssh-keygen-t dsa-p''
- Generating public/private dsa key pair.
- Enter file in which to save the key (/home/aaron/. ssh/id_dsa ):
- Created directory '/home/aaron/. ssh '.
- Your identification has been saved in/home/aaron/. ssh/id_dsa.
- Your public key has been saved in/home/aaron/. ssh/id_dsa.pub.
- The key fingerprint is:
- Bd: 2c: ed: AB: 6d: a9: b2: 45: 88: 32: 08: 5a: d2: d9: ad: cc aaron @ ubuntu
- The key's randomart image is:
- + -- [DSA 1024] ---- +
- |
- |. O. |
- | O +... |
- | O + o... |
- | O E. S. |
- | O. o. |
- | O +. |
- |... + O |
- |. Oo ++. |
- + ----------------- +
$ ssh-keygen -t dsa -P ''Generating public/private dsa key pair.Enter file in which to save the key (/home/aaron/.ssh/id_dsa):Created directory '/home/aaron/.ssh'.Your identification has been saved in /home/aaron/.ssh/id_dsa.Your public key has been saved in /home/aaron/.ssh/id_dsa.pub.The key fingerprint is:bd:2c:ed:ab:6d:a9:b2:45:88:32:08:5a:d2:d9:ad:cc aaron@ubuntuThe key's randomart image is:+--[ DSA 1024]----+| || . o . ||o + . . ||o+ o o . . ||o o E . S . || o . o . || o +. || .. +o || .oo++. |+-----------------+
(Note: After you press enter ~ Two files are generated under/. ssh/: id_rsa and id_rsa.pub. These two files are paired .)
Add the content in id_dsa.pub to the public key file for authentication. The command is as follows:
- $ Cat id_dsa.pub> authorized_keys
$ cat id_dsa.pub >> authorized_keys
You can copy the generated authorized_keys to another machine.
- $ Cat ~ /. Ssh/authorized_keys | \
- Ssh aarron@192.168.1.108 "cat-> ~ /. Ssh/authorized_keys"
$ cat ~/.ssh/authorized_keys | \ssh aarron@192.168.1.108 "cat - >> ~/.ssh/authorized_keys"
Log on to localhost. Enter the command: ssh localhost on the terminal. (Note: After you remotely log on to another machine through ssh, You need to execute the exit command to control the local host again .) Run the exit command. Enter the command: exit
If a problem occurs during the configuration process, the general problem is that the file permission settings are incorrect. Set the access permissions of. ssh and authorized_keys to 755 600, respectively. The command is as follows:
- $ Chmod 755 ~ /. Ssh
- $ Chmod 600 ~ /. Ssh/authorized_keys
$ chmod 755 ~/.ssh$ chmod 600 ~/.ssh/authorized_keys
The above is an example of the Ubuntu platform. The following describes how to configure it on the CentOS platform.
First, set the/etc/ssh/sshd_config file. Remove the comments of the following three lines in the/etc/ssh/sshd_config file:
- $ Sudo vim/etc/ssh/sshd_config
- RSAAuthentication yes
- PubkeyAuthentication yes
- AuthorizedKeysFile. ssh/authorized_keys
$sudo vim /etc/ssh/sshd_configRSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys
The remaining steps are the same as the configuration in Ubuntu.
Related reading:
The whole process of configuring SSH service under Ubuntu and the solution of http://www.linuxidc.com/Linux/2011-09/42775.htm
Install Git, SSH and Permission denied solutions in Ubuntu 12.04 http://www.linuxidc.com/Linux/2013-06/85336.htm
Ubuntu 12.10 OpenSSH offline Installation Method http://www.linuxidc.com/Linux/2013-04/82814.htm
Install or set http://www.linuxidc.com/Linux/2013-07/87368.htm in SSH under Ubuntu
For more information about CentOS, see the CentOS topic page http://www.linuxidc.com/topicnews.aspx? Tid = 14
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2