一、最近想装个Cygwin来模拟unix环境,就到http://www./官网上下载了安装包,然后进行安装,可是在安装完成后,登陆用户却不是root用户,于是开始查找资料。看到许多人说修改/etc/passwd文件,然后就能以root用户登陆,但是我的/etc目录下面根本就没有passwd文件,感觉很郁闷,竟然没有那还还怎么修改呢? cygwin 安装地址: http://cygwin.morrors. http://cygwin. 在网上找了许多资料,关于为什么没有passwd文件的信息很少,自己也不知道如何解决,于是重新安装Cgywin,结果还是一样。经过仔细的查看网友对Cygwin使用的介绍,终于找到了一种解决方法。 由于Cgywin提高了安全性能,没有导入window用户的信息,而是默认以Administrator的普通用户来登陆的,所以我们需要导入windows的用户信息来自己创建passwd文件: 1. 执行如下命令 $mkpasswd -l > /etc/passwd ,创建passwd文件 2. 修改/etc/passwd文件,将Administrator:*:197108:197121:U-PC-20141130ZJVQ\Administrator,S-1-5-21-222170896-2087209242-3699733865-500:/home/Administrator:/bin/bash 修改为root:*:0:0:U-PC-20141130ZJVQ\root,S-1-5-21-222170896-2087209242-3699733865-500:/home/root:/bin/bash 把group和passwd文件里的所有Administrator和Administrators改为root. ##################################### ##################################### # ssh-host-config报错:*** ERROR: Problem with /var/run directory. Exiting: 解决:chgrp Users /var/* chmod 755 /var/* chmod ug-s /var/* chmod +t /var/*
3. 在/home目录下创建root目录 之后,关闭控制台,重新登陆,就会以root用户登陆,修改成功。 二、cygwin安装ssh-host-config $ mkgroup -l > /etc/group $ mkpasswd -l > /etc/passwd $ chmod +r /etc/group $ chmod U+W /etc/group $ chmod +r /etc/passwd $ chmod u+w /etc/passwd $ chmod +rwx /var $ chmod 755 /var $ touch /var/log/sshd.log $ chmod 664 /var/log/sshd.log $ ssh-host-config *** Info: Generating missing SSH host keys *** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes *** Info: Creating default /etc/ssh_config file *** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes *** Info: Creating default /etc/sshd_config file *** Info: StrictModes is set to 'yes' by default. *** Info: This is the recommended setting, but it requires that the POSIX *** Info: permissions of the user's home directory, the user's .ssh *** Info: directory, and the user's ssh key files are tight so that *** Info: only the user has write permissions. *** Info: On the other hand, StrictModes don't work well with default *** Info: Windows permissions of a home directory mounted with the *** Info: 'noacl' option, and they don't work at all if the home *** Info: directory is on a FAT or FAT32 partition. *** Query: Should StrictModes be used? (yes/no) no *** Info: Updating /etc/sshd_config file *** Info: Note that creating a new user requires that the current account have *** Info: Administrator privileges. Should this script attempt to create a *** Query: new local account 'sshd'? (yes/no) yes *** Info: Updating /etc/sshd_config file *** Query: Do you want to install sshd as a service? *** Query: (Say "no" if it is already installed as a service) (yes/no) yes *** Query: Enter the value of CYGWIN for the daemon: [] ntsec tty *** Info: On Windows Server 2003, Windows Vista, and above, the *** Info: SYSTEM account cannot setuid to other users -- a capability *** Info: sshd requires. You need to have or to create a privileged *** Info: account. This script will help you do so. *** Info: It's not possible to use the LocalSystem account for services *** Info: that can change the user id without an explicit password *** Info: (such as passwordless logins [e.g. public key authentication] *** Info: via sshd) when having to create the user token from scratch. *** Info: For more information on this requirement, see *** Info: https:///cygwin-ug-net/ntsec.html#ntsec-nopasswd1 *** Info: If you want to enable that functionality, it's required to create *** Info: a new account with special privileges (unless such an account *** Info: already exists). This account is then used to run these special *** Info: servers. *** Info: Note that creating a new user requires that the current account *** Info: have Administrator privileges itself. *** Info: No privileged account could be found. *** Info: This script plans to use 'cyg_server'. *** Info: 'cyg_server' will only be used by registered services. *** Query: Do you want to use a different name? (yes/no) yes *** Query: Enter the new user name: dev *** Query: Reenter: dev *** Query: Create new privileged user account 'GP-PC\dev' (Cygwin name: 'dev')? (yes/no) yes *** Info: Please enter a password for new user dev. Please be sure *** Info: that this password matches the password rules given on your system. *** Info: Entering no password will exit the configuration. *** Query: Please enter the password: *** Query: Reenter: *** Info: User 'dev' has been created with password '123456'. *** Info: If you change the password, please remember also to change the *** Info: password for the installed services which use (or will soon use) *** Info: the 'dev' account. *** Info: The sshd service has been installed under the 'dev' *** Info: account. To start the service now, call `net start sshd' or *** Info: `cygrunsrv -S sshd'. Otherwise, it will start automatically *** Info: after the next reboot. *** Info: Host configuration finished. Have fun! 输入 启动sshd服务报错:# cygrunsrv --start sshd cygrunsrv: Error starting a service: StartService: Win32 error 1069: 解决方案: 三,配置SSH无密码登陆 $ mkpasswd -l > /etc/passwd $ mkgroup -l > /etc/group $ cygrunsrv -R sshd $ ssh-host-config -y $ cygrunsrv -S sshd
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys 注:>>:追加 chmod 700 ~/.ssh/ 注:~/.ssh 目录的权限必须是700 chmod 600 ~/.ssh/authorized_keys 注:~/.ssh/authorized_keys 文件权限必须是600
验证ssh, $ ssh localhost The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is SHA256:QC6tLuR8oAWqDjdEUdZnYYKI5h7UQMIlsIS48DTpHCc. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. 不需要输入密码即可登录。 cygwin是一个在windows平台上运行的unix模拟环境,是cygnus solutions公司开发的自由软件。它对于学习unix/linux操作环境,或者从unix到windows的应用程序移植,或者进行某些特殊的开发。 Cygwin最新版2.738本地安装包,内附详细的傻瓜式安装教程,专为Android NDK定制,集合make3.8.1、gcc3.4.4,附带一些基本常用命令,本人亲测成功。 测试版本:Android-NDK-r5 安装在Windows上,可以运行bash,vi,g cygwin本地安装版安装教程:1、 双击运行cyg_win_setup.exe 安装程序安装时,请用管理员账户安装(你的电脑的登录用户是Administor身份)!!安装过程中,有时候会停止不动,不要强行关闭,不是死机,只是进行的很慢! 2. 选择"Install from Local Directory"安装; 3、选择安装包时不建议都选上,因为安装时间较长、占用磁盘空间过大。 4、配置环境变量时,JAVA_HOME指向jdk安装目录,Path路径中添加JDK的bin目录、jre的bin目录和Cygwin的bin目录,usr的sbin目录; ( 5、建议修改.sh文件时,使用vi命令修改。 【安装成功后注意:】 (使用Cygwin Terminal,更改其相关属性option,相关信息会生成在.minttyrc文件中) 2). 修改Cygwin编码 固定修改: cygwin\home\username\.inputrc 3). cygwin怎么用?1、cygwin使用心得 2、 就可以直接在cmd.exe下面执行tar czvf xxx.tgz ./ 3、使用TGZ备份 4.恢复Cygwin快捷方式 这里介绍手动创建Cygwin的快捷方式。 (1)首先说明一点,Cygwin的快捷方式实际上是指向一个名为Cygwin.bat的批处理文件,而不是大家常见到的.exe文件。其实原理是一样的,批处理文件跟exe文件一样都是可执行文件,不同的是现在批处理很少见了,而安全防卫软件通常就把批处理文件当成有问题程序给删掉了。 (2)找到Cygwin安装文件夹,本人安装在D:\cygwin,注意这个文件应该是真正的程序存放位置,这个目录下必须有这几个文件夹:bin, cygdriver, dev, etc, home, lib… 。 现在在刚才的目录下(D:\cygwin)创建文件 “Cygwin.bat”,注意:后缀一定是.bat。 然后编辑此文件,在其中加入如下代码: @echo off 最后给此文件创建快捷方式到桌面 现在工作基本完成了,唯一不足的是刚才创建的快捷方式图标是刚才的批处理文件的图标,而不是原先安装时的图标。 (3)在刚才的文件夹(D:\cygwin)下找到Cygwin.ico,正是这个图片。 现在到刚才的快捷方式上:右键–>属性–>更改图标–>浏览–>找到Cygwin.ico–>确定 6、.命令 --help查看该命令的帮助; 文件/目录权限设置命令:chmod 这是Linux系统管理员最常用到的命令之一, |
|
来自: 关平藏书 > 《Hadoop家族》