一、最近想裝個(gè)Cygwin來(lái)模擬unix環(huán)境,,就到http://www./官網(wǎng)上下載了安裝包,,然后進(jìn)行安裝,可是在安裝完成后,,登陸用戶(hù)卻不是root用戶(hù),,于是開(kāi)始查找資料??吹皆S多人說(shuō)修改/etc/passwd文件,,然后就能以root用戶(hù)登陸,但是我的/etc目錄下面根本就沒(méi)有passwd文件,,感覺(jué)很郁悶,,竟然沒(méi)有那還還怎么修改呢? cygwin 安裝地址: http://cygwin.morrors. http://cygwin. 在網(wǎng)上找了許多資料,,關(guān)于為什么沒(méi)有passwd文件的信息很少,,自己也不知道如何解決,于是重新安裝Cgywin,,結(jié)果還是一樣,。經(jīng)過(guò)仔細(xì)的查看網(wǎng)友對(duì)Cygwin使用的介紹,,終于找到了一種解決方法。 由于Cgywin提高了安全性能,,沒(méi)有導(dǎo)入window用戶(hù)的信息,,而是默認(rèn)以Administrator的普通用戶(hù)來(lái)登陸的,所以我們需要導(dǎo)入windows的用戶(hù)信息來(lái)自己創(chuàng)建passwd文件: 1. 執(zhí)行如下命令 $mkpasswd -l > /etc/passwd ,,創(chuàng)建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報(bào)錯(cuò):*** ERROR: Problem with /var/run directory. Exiting: 解決:chgrp Users /var/* chmod 755 /var/* chmod ug-s /var/* chmod +t /var/*
3. 在/home目錄下創(chuàng)建root目錄 之后,關(guān)閉控制臺(tái),,重新登陸,,就會(huì)以root用戶(hù)登陸,修改成功,。 二,、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! 輸入 啟動(dòng)sshd服務(wù)報(bào)錯(cuò):# cygrunsrv --start sshd cygrunsrv: Error starting a service: StartService: Win32 error 1069: 解決方案: 三,,配置SSH無(wú)密碼登陸 $ 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 目錄的權(quán)限必須是700 chmod 600 ~/.ssh/authorized_keys 注:~/.ssh/authorized_keys 文件權(quán)限必須是600
驗(yàn)證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是一個(gè)在windows平臺(tái)上運(yùn)行的unix模擬環(huán)境,,是cygnus solutions公司開(kāi)發(fā)的自由軟件,。它對(duì)于學(xué)習(xí)unix/linux操作環(huán)境,或者從unix到windows的應(yīng)用程序移植,,或者進(jìn)行某些特殊的開(kāi)發(fā),。 Cygwin最新版2.738本地安裝包,內(nèi)附詳細(xì)的傻瓜式安裝教程,,專(zhuān)為Android NDK定制,,集合make3.8.1、gcc3.4.4,,附帶一些基本常用命令,,本人親測(cè)成功。 測(cè)試版本:Android-NDK-r5 安裝在Windows上,,可以運(yùn)行bash,vi,g cygwin本地安裝版安裝教程:1,、 雙擊運(yùn)行cyg_win_setup.exe 安裝程序安裝時(shí),請(qǐng)用管理員賬戶(hù)安裝(你的電腦的登錄用戶(hù)是Administor身份)??!安裝過(guò)程中,有時(shí)候會(huì)停止不動(dòng),,不要強(qiáng)行關(guān)閉,,不是死機(jī),只是進(jìn)行的很慢,! 2. 選擇"Install from Local Directory"安裝,; 3,、選擇安裝包時(shí)不建議都選上,因?yàn)榘惭b時(shí)間較長(zhǎng),、占用磁盤(pán)空間過(guò)大,。 4,、配置環(huán)境變量時(shí),,JAVA_HOME指向jdk安裝目錄,Path路徑中添加JDK的bin目錄,、jre的bin目錄和Cygwin的bin目錄,usr的sbin目錄,; ( 5,、建議修改.sh文件時(shí),使用vi命令修改,。 【安裝成功后注意:】 (使用Cygwin Terminal,,更改其相關(guān)屬性option,相關(guān)信息會(huì)生成在.minttyrc文件中) 2). 修改Cygwin編碼 固定修改: cygwin\home\username\.inputrc 3). cygwin怎么用,?1,、cygwin使用心得 2、 就可以直接在cmd.exe下面執(zhí)行tar czvf xxx.tgz ./ 3,、使用TGZ備份 4.恢復(fù)Cygwin快捷方式 這里介紹手動(dòng)創(chuàng)建Cygwin的快捷方式,。 (1)首先說(shuō)明一點(diǎn),,Cygwin的快捷方式實(shí)際上是指向一個(gè)名為Cygwin.bat的批處理文件,而不是大家常見(jiàn)到的.exe文件,。其實(shí)原理是一樣的,,批處理文件跟exe文件一樣都是可執(zhí)行文件,不同的是現(xiàn)在批處理很少見(jiàn)了,,而安全防衛(wèi)軟件通常就把批處理文件當(dāng)成有問(wèn)題程序給刪掉了,。 (2)找到Cygwin安裝文件夾,本人安裝在D:\cygwin,,注意這個(gè)文件應(yīng)該是真正的程序存放位置,,這個(gè)目錄下必須有這幾個(gè)文件夾:bin, cygdriver, dev, etc, home, lib… 。 現(xiàn)在在剛才的目錄下(D:\cygwin)創(chuàng)建文件 “Cygwin.bat”,,注意:后綴一定是.bat,。 然后編輯此文件,在其中加入如下代碼: @echo off 最后給此文件創(chuàng)建快捷方式到桌面 現(xiàn)在工作基本完成了,,唯一不足的是剛才創(chuàng)建的快捷方式圖標(biāo)是剛才的批處理文件的圖標(biāo),,而不是原先安裝時(shí)的圖標(biāo)。 (3)在剛才的文件夾(D:\cygwin)下找到Cygwin.ico,,正是這個(gè)圖片,。 現(xiàn)在到剛才的快捷方式上:右鍵–>屬性–>更改圖標(biāo)–>瀏覽–>找到Cygwin.ico–>確定 6、.命令 --help查看該命令的幫助,; 文件/目錄權(quán)限設(shè)置命令:chmod 這是Linux系統(tǒng)管理員最常用到的命令之一,, |
|
來(lái)自: 關(guān)平藏書(shū) > 《Hadoop家族》