免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 41952 | 回复: 8
打印 上一主题 下一主题

ubuntu安装ssh无法连接解决日志(已解决,可连接) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-08-23 12:59 |只看该作者 |倒序浏览
  1. 网上有很多介绍在Ubuntu下开启SSH服务的文章,但大多数介绍的方法测试后都不太理想,均不能实现远程登录到Ubuntu上,最后分析原因是都没有真正开启ssh-server服务。最终成功的方法如下:

  2. sudo apt-get install openssh-server

  3. Ubuntu缺省安装了openssh-client,所以在这里就不安装了,如果你的系统没有安装的话,再用apt-get安装上即可。

  4. 然后确认sshserver是否启动了:

  5. ps -e |grep ssh

  6. 如果只有ssh-agent那ssh-server还没有启动,需要/etc/init.d/ssh start,如果看到sshd那说明ssh-server已经启动了。

  7. ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。然后重启SSH服务:

  8. sudo /etc/init.d/ssh resar

  9. ssh连接:ssh linuxidc@192.168.1.1

  10. 摘自:http://www.linuxidc.com/Linux/2010-02/24349.htm
复制代码
然后本机连接,出现了英文,本人自幼在中国生长,不懂得鸟语!所以研究了很久! 后来找到了http://www.unixtutorial.org/2009 ... re-shell-in-ubuntu/,马上如有天助,跟我遇到的问题都一样!原来是要输入yes阿!我习惯性的输入的都是y,哎!看样子也的看清楚答问题阿!
  1. SSH (Secure SHell) is possibly the best way to remotely access a Unix system – it's very secure thanks to automatic encryption of all the traffic, and it's also quite universal because you can do all sorts of things: access remote command line shell, forward graphics session output, establish network tunnels and set up port redirections. Today I'm going to show you how to get started with SSH in Ubuntu.
  2. Installing SSH server in Ubuntu

  3. By default, your system will have no SSH service enabled, which means you won't be able to connect to it remotely using SSH protocol (TCP port 22). This means that installing SSH server will be one of the first post-install steps on your system.

  4. The most common SSH implementation is OpenSSH server, and that's exactly what you want to install.

  5. Log in with your standard username and password, and run the following command to install openssh-server. You should be using the same username that you specified when installing Ubuntu, as it will be the only account with sudo privileges to run commands as root:

  6. ubuntu$ sudo apt-get install openssh-server
  7. [sudo] password for greys:
  8. Reading package lists... Done
  9. Building dependency tree
  10. Reading state information... Done
  11. Suggested packages:
  12.   rssh molly-guard openssh-blacklist openssh-blacklist-extra
  13. The following NEW packages will be installed:
  14.   openssh-server
  15. 0 upgraded, 1 newly installed, 0 to remove and 75 not upgraded.
  16. Need to get 285kB of archives.
  17. After this operation, 782kB of additional disk space will be used.
  18. Get:1 http://ie.archive.ubuntu.com jaunty/main openssh-server 1:5.1p1-5ubuntu1 [
  19. 285kB]
  20. Fetched 285kB in 0s (345kB/s)
  21. Preconfiguring packages ...
  22. Selecting previously deselected package openssh-server.
  23. (Reading database ... 101998 files and directories currently installed.)
  24. Unpacking openssh-server (from .../openssh-server_1%3a5.1p1-5ubuntu1_i386.deb) .
  25. ..
  26. Processing triggers for ufw ...
  27. Processing triggers for man-db ...
  28. Setting up openssh-server (1:5.1p1-5ubuntu1) ...
  29. Creating SSH2 RSA key; this may take some time ...
  30. Creating SSH2 DSA key; this may take some time ...
  31. * Restarting OpenBSD Secure Shell server sshd                           [ OK ]

  32. Verifying your SSH server works

  33. While you're still on your local desktop session, you can use the ps command to confirm that SSH daemon (sshd) is running:

  34. ubuntu$ ps -aef | grep sshd
  35. root     24114     1  0 15:18 ?        00:00:00 /usr/sbin/sshd

  36. Now that you see it's there, it's time to try connecting:

  37. ubuntu$ ssh localhost

  38. Since this is the first time you're trying to connect using SSH, you'll have to answer yes to the following question:

  39. The authenticity of host 'localhost (::1)' can't be established.
  40. RSA key fingerprint is 18:4d:96:b3:0d:25:00:c8:a1:a3:84:5c:9f:1c:0d:a5.
  41. Are you sure you want to continue connecting (yes/no)? yes

  42. … you'll then be prompted for your own password (remember, the system treats such connection request as if you were connecting remotely, so it can't trust you without confirming your password):

  43. Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
  44. greys@localhost's password:

  45. .. and finally you'll see the usual Ubuntu (Jaunty in this example) banner and prompt:

  46. Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686

  47. The programs included with the Ubuntu system are free software;
  48. the exact distribution terms for each program are described in the
  49. individual files in /usr/share/doc/*/copyright.

  50. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
  51. applicable law.

  52. To access official Ubuntu documentation, please visit:

  53. http://help.ubuntu.com/

  54. Last login: Fri May 15 15:18:34 2009 from ubuntu
  55. ubuntu$

  56. That's it, providing you have your networking configured and you know your IP address or hostname, you can start connecting to your Ubuntu box from remote systems, using the same command.  Enjoy!
复制代码
然后本机是可以连接了!但是外部用putty还是不行!sudo ufw disable 关闭ufw防火墙,发现貌似根本没开!(也上网查了,自己不装,系统不会安装的!)
后来在http://forum.ubuntu.org.cn/viewtopic.php?t=40438,找到了这一行,貌似是系统的安全规则
  1. iptables是内核模块删除不了滴
  2. 现查看一下你iptables的规则
  3. sudo iptables -L
  4. sudo iptables -t nat -L
  5. 如果都是空的就不是iptables的问题
  6. 如果有许多规则的话就清空规则并修改默认策略
  7. sudo iptables -F
  8. sudo iptables -t nat -F
  9. sudo iptables -P ACCEPT
  10. sudo iptables -t nat -P ACCEPT
复制代码
按着弄了一遍!最后两条都出现问题了!忘记截图了!好像是说没有这个命令,请查阅help什么的!不管!弄完,我去别的电脑上用putty连接,出现证书验证,yes,进入了!输入用户名后,有点慢,修改sudo gedit /etc/ssh/sshd_config
  1. 找到 GSSAPI options 这一节,将下面两行注释掉:

  2.     #GSSAPIAuthentication yes
  3.     #GSSAPIDelegateCredentials no

  4. 然后重新启动 ssh 服务即可:

  5.     sudo /etc/init.d/ssh restart

  6. 摘自:http://blog.istef.info/2008/10/02/setup-ssh-server-on-ubuntu-server/
复制代码
我的本来就是注释掉了阿!呵呵!不修改了!
以上是我安装ssh,解决的全过程!留着备用!

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
2 [报告]
发表于 2011-08-23 14:56 |只看该作者
谢谢分享。

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
3 [报告]
发表于 2011-08-23 20:46 |只看该作者
ssh连接慢的情况,修改/etc/ssh/sshd_config,将usedns设置成no

论坛徽章:
0
4 [报告]
发表于 2011-08-23 21:22 |只看该作者
ssh连接慢的情况,修改/etc/ssh/sshd_config,将usedns设置成no
chenyx 发表于 2011-08-23 20:46

没有那一项!我添加进去了!

论坛徽章:
0
5 [报告]
发表于 2011-08-23 21:31 |只看该作者
解决!速度明显快了很多!
以前输入用户名后都得等一会,现在不用了!
重启服务!截图上!

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
6 [报告]
发表于 2011-08-23 21:48 |只看该作者
回复 5# pcxys


    现在不用输入用户名了?

论坛徽章:
0
7 [报告]
发表于 2011-08-23 22:27 |只看该作者
肯定的还得输入用户名阿!不输入用户名得需要什么证书!我的头贴里面好像是有方法!

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
8 [报告]
发表于 2011-08-23 22:37 |只看该作者
嗯,禁用dns反解速度快很多的

论坛徽章:
0
9 [报告]
发表于 2011-08-23 23:20 |只看该作者
恩!了解了!谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP