Original: http://www.cnblogs.com/eastson/archive/2012/06/29/2570163.html
With the CentOS 6.2 installed, I want it to be a server that allows my Windows 7 computer to log on remotely.
Installing OpenSSH Server
First, let's search the CentOS software library for an SSH server package that has been defined:
$ yum Search ssh ...
Openssh.x86_64:An Open Source implementation of SSH protocol versions 1 and 2
openssh-askpass.x86_64:a passphrase Dialog for OpenSSH and X
Openssh-clients.x86_64:an Open source SSH client applications
openssh-ldap.x86_64:a L DAP support for open source SSH server daemon
openssh-server.x86_64:an open source ssh server daemon
...
OpenSSH is an open source implementation of the secure shell. As you can see from the search results above, CentOS's software library already has OpenSSH server packs (Openssh-server) and client packs (openssh-clients), which can be installed directly with Yum install.
$ yum Install Openssh-server
After the OpenSSH server installation is complete, a service named sshd should be added to the/ETC/INIT.D directory. You can refer to the "CentOS set up the service start automatically" way to configure the SSHD service to boot automatically.
$ chkconfig--list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on
Manually start the SSHD service to facilitate subsequent client connections:
$/etc/init.d/sshd Start
Log on to a remote server in a password way
SSH client software in WIndows 7 I'm using a xshell. Open Xshell, create a new connection, select Password Authentication mode, enter a username and password, and then connect to the server.
The screen after successful login:
Log on to a remote server with an RSA key
OpenSSH allows you to log on to the server using RSA. RSA encryption will have two files: one is the public key file, placed in the server $home/.ssh/authorized_keys file, and the other is the private key file, placed on the client computer.
Generates an RSA key pair that can be generated on the server or generated at the client:
$ ssh-keygen
After execution, two more files are added to the $HOME/.SSH directory: id_rsa.pub (public key file) and Id_rsa (private key file).
Append the public key file to the $home/.ssh/authorized_keys file:
$ cat Id_rsa.pub >> Authorized_keys
Download the private key file to the client computer (you can use SFTP methods, such as XFTP,WINSCP, etc.), and then create a new Xshell connection and select Public key authentication method:
Configuration is complete, now we can connect to the server without entering a password.
OpenSSH related directories and files
Directories saved by all configuration information:/etc/ssh
SSHD service profile:/etc/ssh/sshd_config
OpenSSH RELATED LINKS
Build SSH server with OpenSSH: Install the O-basin SSH server.
"Log on to the server with SSH client software": How to use Putty+rsa to log on to a remote server.
"CentOS Wiki-Defend OpenSSH": OpenSSH security settings.
Top OpenSSH Server Best security Practices: 20 SSH safety recommendations that need to be followed.