windows 访问ubuntu (ssh-server 安装及使用)

来源:互联网 发布:淘宝特别促销方案 编辑:程序博客网 时间:2024/06/06 01:39

Ubuntu11环境oepnssh-server安装配置

本人按照此博客文章在ubuntu14.04也已经成功安装了。

1、环境:

Ubuntu11.04

 

2、安装

Ubuntu提供了便利的apt工具,采用在线安装依赖包将会自动下载并安装。

 

Python代码  收藏代码
  1. sudo apt-get install openssh-server  

 

 


 

3、安装过程

    下载过程视网速而定,很小的317K,如果不拨号很速度。


 

4、启动、停止ssh服务

 

 

Python代码  收藏代码
  1. cd /etc/init.d  
  2. //启动ssh服务  
  3. service ssh start  
  4. //停止ssh服务  
  5. service ssh stop  
  6. //重启ssh服务  
  7. service ssh restart  

 


 

5、查看是否启动

     如果有sshd服务说明ssh server已经启动,也可以直接start(别restart,这是重启),如果已经启动会提示。

 

 

Java代码  收藏代码
  1. ps -d|grep ssh  

  或者

 

Ruby代码  收藏代码
  1. pidof sshd  

 


 

6、高级技巧

     openssh-server安装后剩下的工作就是配置,配置信息位于sshd_config文件,一行一个配置,#开头的行表示注释。配置内容 key=value形式出现。

Sshd_config代码  收藏代码
  1. # Package generated configuration file  
  2. # See the sshd_config(5) manpage for details  
  3.   
  4. # What ports, IPs and protocols we listen for  
  5. #监听端口,可以修改为其他端口默认22  
  6. Port 22  
  7. # Use these options to restrict which interfaces/protocols sshd will bind to  
  8. #ListenAddress ::  
  9. #监听IP,去掉注释标示监听所有ip地址  
  10. #ListenAddress 0.0.0.0  
  11. #协议版本号  
  12. Protocol 2  
  13. # HostKeys for protocol version 2  
  14. HostKey /etc/ssh/ssh_host_rsa_key  
  15. HostKey /etc/ssh/ssh_host_dsa_key  
  16. HostKey /etc/ssh/ssh_host_ecdsa_key  
  17. #Privilege Separation is turned on for security  
  18. UsePrivilegeSeparation yes  
  19.   
  20. # Lifetime and size of ephemeral version 1 server key  
  21. KeyRegenerationInterval 3600  
  22. ServerKeyBits 768  
  23.   
  24. # Logging  
  25. SyslogFacility AUTH  
  26. #ssh登陆日志写入AUTH系统日志设备,建议级别:VERBOSE  
  27. LogLevel INFO  
  28.   
  29. # Authentication:  
  30. #连接ubuntu120秒内登陆ssh,否则断开。  
  31. LoginGraceTime 120  
  32. #是否允许root登陆ssh,如果设置可能su root失败  
  33. PermitRootLogin yes  
  34. #设置SSH在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权。防止目录和文件设置成任何人都有写权限  
  35. StrictModes yes  
  36.   
  37. RSAAuthentication yes  
  38. PubkeyAuthentication yes  
  39. #AuthorizedKeysFile %h/.ssh/authorized_keys  
  40.   
  41. # Don't read the user's ~/.rhosts and ~/.shosts files  
  42. IgnoreRhosts yes  
  43. # For this to work you will also need host keys in /etc/ssh_known_hosts  
  44. RhostsRSAAuthentication no  
  45. # similar for protocol version 2  
  46. HostbasedAuthentication no  
  47. # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication  
  48. #IgnoreUserKnownHosts yes  
  49.   
  50. # To enable empty passwords, change to yes (NOT RECOMMENDED)  
  51. PermitEmptyPasswords no  
  52.   
  53. # Change to yes to enable challenge-response passwords (beware issues with  
  54. # some PAM modules and threads)  
  55. ChallengeResponseAuthentication no  
  56.   
  57. # Change to no to disable tunnelled clear text passwords  
  58. #PasswordAuthentication yes  
  59.   
  60. # Kerberos options  
  61. #KerberosAuthentication no  
  62. #KerberosGetAFSToken no  
  63. #KerberosOrLocalPasswd yes  
  64. #KerberosTicketCleanup yes  
  65.   
  66. # GSSAPI options  
  67. #GSSAPIAuthentication no  
  68. #GSSAPICleanupCredentials yes  
  69.   
  70. X11Forwarding yes  
  71. X11DisplayOffset 10  
  72. PrintMotd no  
  73. #设置是否打印最用户最后一次登陆时间。例如:Last login: Tue May 17 13:58:15 2011 from localhost  
  74. PrintLastLog yes  
  75. #是否发送心跳包  
  76. TCPKeepAlive yes  
  77. #UseLogin no  
  78.   
  79. #MaxStartups 10:30:60  
  80. #激活警示条,警示未经许可用户登陆  
  81. #Banner /etc/issue.net  
  82.   
  83. # Allow client to pass locale environment variables  
  84. AcceptEnv LANG LC_*  
  85.   
  86. #配置外部子系统,参数为子系统名字、执行命令  
  87. Subsystem sftp /usr/lib/openssh/sftp-server  
  88.   
  89. # Set this to 'yes' to enable PAM authentication, account processing,  
  90. # and session processing. If this is enabled, PAM authentication will  
  91. # be allowed through the ChallengeResponseAuthentication and  
  92. # PasswordAuthentication.  Depending on your PAM configuration,  
  93. # PAM authentication via ChallengeResponseAuthentication may bypass  
  94. # the setting of "PermitRootLogin without-password".  
  95. # If you just want the PAM account and session checks to run without  
  96. # PAM authentication, then enable this but set PasswordAuthentication  
  97. # and ChallengeResponseAuthentication to 'no'.  
  98. UsePAM yes 
0 0