Linux平台下安装SSH


什么是SSH?Secure Shell(缩写为SSH),由IETF的网络工作小组(Network Working Group)所制定;SSH为一项创建在应用层和传输层基础上的安全协议,为计算机上的Shell(壳层)提供安全的传输和使用环境。传统的网络服务程序,如rsh、FTP、POP和Telnet其本质上都是不安全的;因为它们在网络上用明文传送数据、用户帐号和用户口令,很容易受到中间人(man-in-the-middle)攻击方式的攻击。就是存在另一个人或者一台机器冒充真正的服务器接收用户传给服务器的数据,然后再冒充用户把数据传给真正的服务器。而SSH是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议。利用SSH协议可以有效防止远程管理过程中的信息泄露问题。通过SSH可以对所有传输的数据进行加密,也能够防止DNS欺骗和IP欺骗。SSH之另一项优点为其传输的数据可以是经过压缩的,所以可以加快传输的速度。SSH有很多功能,它既可以代替Telnet,又可以为FTP、POP、甚至为PPP提供一个安全的“通道”。

下面以CentOS平台为例,说明怎么安装ssh服务器。下面为了方便,都是以root用户权限去操作,实际情况下,请使用一般用户权限去使用,只需要加入sudo就行。

[root@localhost ~]# yum install openssh-server
这样就可以安装好ssh-server了。
  检验SSH是否安装好了,可以用下面的命令:

[bkjia@localhost ~]$ ssh -version
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
Bad escape character 'rsion'.
如果显示上面的信息,说明安装好了SSH。

  有些用户可能会问,我怎么记地是安装openssh-server而不是直接yum install ssh呢?这里告诉大家一个方法(CentOS平台),可以快速知道我们需要安装程序的名称。如下:

[root@localhost ~]# yum search ssh
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: www.ftp.ne.jp
============================= N/S Matched: ssh =============================
ksshaskpass.x86_64 : A KDE version of ssh-askpass with KWallet support
libssh2.i686 : A library implementing the SSH2 protocol
libssh2.x86_64 : A library implementing the SSH2 protocol
libssh2-devel.i686 : Development files for libssh2
libssh2-devel.x86_64 : Development files for libssh2
libssh2-docs.x86_64 : Documentation for libssh2
openssh.x86_64:An open source implementation of SSH protocol versions 1and 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 LDAP support for open source SSH server daemon
openssh-server.x86_64 : An open source SSH server daemon
pam_ssh_agent_auth.i686 : PAM module for authentication with ssh-agent
pam_ssh_agent_auth.x86_64 : PAM module for authentication with ssh-agent
trilead-ssh2.noarch : SSH-2 protocol implementation in pure Java
trilead-ssh2-javadoc.noarch : Javadoc for trilead-ssh2
jsch.noarch : Pure Java implementation of SSH2
python-paramiko.noarch : A SSH2 protocol library for python
python-twisted-conch.x86_64 : SSH and SFTP protocol implementation
together with clients and servers

  Name and summary matches only, use "search all" for everything.
从上面我们可以看到openssh-server,这就是我们需要安装的程序名称。
如果你是Ubuntu平台呢?没关系,可以运行下面的命令,也可以达到上面一样的效果

[root@localhost ~]# apt-get update //这行可以不要
[root@localhost ~]# apt-cache search ssh
  下面我们列出ssh服务sshd在各个执行等级的启动情况:

[root@localhost ~]# chkconfig --list sshd
sshd      0:off    1:off    2:off    3:off    4:off    5:off    6:off
手动启动sshd服务(需要root权限),命令如下:

[root@localhost ~]# /etc/init.d/sshd start
Generating SSH1 RSA host key:                              [  OK  ]
Generating SSH2 RSA host key:                              [  OK  ]
Generating SSH2 DSA host key:                              [  OK  ]
Starting sshd:                                            [  OK  ]
这样可以在putty或别的客户端登录到这台Linux机器了。如果需要停止ssh服务可以运行下面的命令

[root@localhost ~]# /etc/init.d/sshd stop
Stopping sshd:                                            [  OK  ]

Ubuntu 下配置 SSH服务全过程及问题解决

Ubuntu 12.04下安装Git,SSH及出现的Permission denied解决办法

Ubuntu 12.10下OpenSSH的离线安装方法

Ubuntu下SSH安装或设置

相关内容

    暂无相关文章