Linux平臺下安裝SSH

下面以CentOS平臺爲例,說明怎麼安裝ssh服務器。下面爲了方便,都是以root用戶權限去操做,實際狀況下,請使用通常用戶權限去使用,只須要加入sudo就行。java

[root@localhost  ~]# yum install openssh-server
這樣就能夠安裝好ssh-server了。
  檢驗SSH是否安裝好了,能夠用下面的命令:python

[linuxidc@localhost  ~]$ ssh -version
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
Bad escape character 'rsion'.
若是顯示上面的信息,說明安裝好了SSH。linux

  有些用戶可能會問,我怎麼記地是安裝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 serversapp

  Name and summary matches only, use "search all" for everything.
從上面咱們能夠看到openssh-server,這就是咱們須要安裝的程序名稱。
若是你是Ubuntu平臺呢?不要緊,能夠運行下面的命令,也能夠達到上面同樣的效果ssh

[root@localhost  ~]# apt-get update //這行能夠不要
[root@localhost  ~]# apt-cache search ssh
  下面咱們列出ssh服務sshd在各個執行等級的啓動狀況:spa

[root@localhost ~]# chkconfig --list sshd
sshd      0:off    1:off    2:off    3:off    4:off    5:off    6:off
手動啓動sshd服務(須要root權限),命令以下:.net

[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服務能夠運行下面的命令rest

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

linux下面如何設置SSH服務開機啓動

chkconfig --level 2345 sshd on
--level 指定系統在2345運行級別時,一般在35中開啓就行,開啓(on)sshd服務,關閉則用(off)

臨時控制啓動中止則用:/etc/rc.d/init.d/sshd start | stop | restart
相關文章
相關標籤/搜索