• Windows8 上用Ubuntu-Ubuntu启动SSH


    1. 公司刚给配了一个电脑,华硕的超级本8个G的内存,很强大的了,但是系统是64位的windows 8,我用wubi.exe直接安装到系统上,但是开机启动的时候总是下面这个错误,去Ubuntu社区请教,结论是用wubi.exe出现这个问题还没有解决办法没有。QQ图片20140321164542无奈,只好放弃直接安装,用虚拟机安装。
    2. 用windows8自带的Hyper-V虚拟机安装了ubuntu12.04.4版本。幸亏这篇文章Hyper-V虚拟机联网设置,帮我设置了用Hyper-V的虚拟机上网。我现在已经能够正常的使用Ubuntu了。但是感觉虚拟机里操作很不爽决定启动SSH用我的XShell终端来访问。
    3. 启动ubuntu的SSH服务:
    • 我的ubuntu默认没有安装SSH服务:查看一下
      harvey@harvey-Virtual-Machine:~$ ps -e |grep ssh
       1670 ?        00:00:00 ssh-agent #用ps查看进程信息,如果只是显示这一条,说明系统只有SSH客户端没有服务器
    • 因为系统没有安装SSH服务,所以我首先安装openssh-server软件
      harvey@harvey-Virtual-Machine:~$ sudo apt-get install openssh-server
      正在读取软件包列表... 完成
      正在分析软件包的依赖关系树       
      正在读取状态信息... 完成       
      将会安装下列额外的软件包:
    • 安装完成后查看一下SSH进程:
      harvey@harvey-Virtual-Machine:~$ ps -e|grep ssh
       1670 ?        00:00:00 ssh-agent
       3768 ?        00:00:00 sshd 
      #有了sshd说明我的ssh服务安装和启动了

    在介绍下面的知识之前先进性一个小的插曲--介绍一些service命令:

    harvey@harvey-Virtual-Machine:~$ which service #查看service命令ide文件路径
    /usr/sbin/service
    harvey@harvey-Virtual-Machine:~$ file /usr/sbin/service 
    /usr/sbin/service: POSIX shell script, ASCII text executable #file命令发现service命令是一个shell脚本文件
        #分析service的脚本发现此命令的作用是去/etc/init.d目录下寻找相应的服务,进性开始和关闭等操作。service使用的参数start可以换成restart表示重新启动,stop表示关闭,reload表示重新载入配置
    #其实不是所有的linux发行版本中都有service命令,我们完全可以用/etc/init.d/ssh来启动或关闭服务。
    #service开启ssh服务
    harvey@harvey-Virtual-Machine:~$ sudo service ssh start 
    ssh start/running, process 6505
    harvey@harvey-Virtual-Machine:~$ ps -e|grep "ssh"
     5217 ?        00:00:00 ssh-agent <defunct>
     6505 ?        00:00:00 sshd
    
    #service关闭ssh服务
    harvey@harvey-Virtual-Machine:~$ sudo service ssh stop
    ssh stop/waiting
    harvey@harvey-Virtual-Machine:~$ ps -e|grep "ssh"
     5217 ?        00:00:00 ssh-agent <defunct>
    
    #ubunt下直接用
    /etc/init.d/
    ssh的命令的提示是建议不要用直接的命令而是用service命令,因为ubuntu采用的是混合init的方式,所以直接用脚本可能不可用
    harvey@harvey-Virtual-Machine:~$ sudo /etc/init.d/ssh stop
    [sudo] password for harvey: 
    Rather than invoking init scripts through /etc/init.d, use the service(8)
    utility, e.g. service ssh stop
    
    Since the script you are attempting to invoke has been converted to an
    Upstart job, you may also use the stop(8) utility, e.g. stop ssh
    ssh stop/waiting

    查找/etc下ssh相关的配置文件:

    harvey@harvey-Virtual-Machine:~$ find /etc -name "ssh" 
    #可以直接这样搜索因为首先配置文件肯定在/
    etc文件夹下面,而是肯定是ssh开头这是规律
    /etc/ssh
    /etc/init.d/ssh
    find: `/etc/cups/ssl': 权限不够
    find: `/etc/ssl/private': 权限不够
    /etc/bash_completion.d/ssh
    /etc/default/ssh

    参考资料:linux service命令

    OpenSSH简介

  • 相关阅读:
    Hibernate在自由状态和持久的状态转变
    JS日期时间选择器
    LevelDB初体验
    java多线程样例
    PHP 的解压缩ZipArchive中的extractTo()方法 LINUX+nginx环境中解压zip时文件丢失的问题
    JavaScript--基于对象的脚本语言学习笔记(三)
    什么是消息队列?
    android 环境使用smack 必须注冊的组件
    AssetManager asset的使用
    键盘过滤驱动
  • 原文地址:https://www.cnblogs.com/zhanghaiyublog/p/3616701.html
Copyright © 2020-2023  润新知