寻觅生命中的那一片浅草......

文章属于类别 Cygwin

将Cygwin换成Cygwin64导致sshd无法使用一例

问题:
openssh /bin/bash: Operation not permitted
connection closed ::1 或者 connection closed 127.0.0.1

解决办法:
计算机,管理,用户,把cyg_server,sshd这2个用户删掉
vi /etc/passwd 同样把上面的2个用户删掉
ssh-host-config -y就可以了
如果还是不行,试试以管理员身份运行Cygwin.bat

参考文章:http://cygwin.1069669.n5.nabble.com/ssh-logon-failure-td57002.html

SecureCRT批量配置使用会话key

部分服务器使用单独的key,为了方便,写了这2个脚本

2个版本,都需要Python
Windows版
win_crt_conf.py

cygwin版
cygwin_crt_conf.py

cygwin下可以用find+sed+unix2dos实现,但真的太慢了,Python快啊

2个文件要修改的地方是一样的

需要使用单独key的SecureCRT配置文件目录
crt_conf_dir = ‘E:\\CRT_CONF’

定义key文件的位置,identify为private key的名字
key_path_new = ‘S:”Identity Filename”=E:\CRT_KEY\identify’

原理,每个服务器配置都定义了使用全局key还是会话key
这个是使用全局key
D:”Use Global Public Key”=00000001
定义使用的key文件路径
S:”Identity Filename”=

定义使用会话key
D:”Use Global Public Key”=00000000

E:\CRT_KEY\identify为要使用的会话key
S:”Identity Filename”=E:\CRT_KEY\identify
win_crt_conf.py
[python]
#!D:\\Python27\\python
#-*-coding=utf-8-*-

import os,sys,re

crt_conf_dir = ‘E:\\CRT_CONF’
global_public_key_true = ‘D:”Use Global Public Key”=00000001’
global_public_key_false = ‘D:”Use Global Public Key”=00000000’
key_path_old = ‘S:”Identity Filename”=’
key_path_new = ‘S:”Identity Filename”=E:\CRT_KEY\identify’

re_global_public_key = re.compile(global_public_key_true,re.DOTALL)
re_key_path = re.compile(‘S:”Identity Filename”=(.*)’)

os.chdir(crt_conf_dir)

c1 = os.walk(os.getcwd())

filelist = []

for c2 in c1:
for c3 in c2[2]:
filelist.append(os.path.join(c2[0],c3))

for filename in filelist:
fileread = open(filename,’r’)
filer = fileread.read()
pub_key = re.sub(re_global_public_key,global_public_key_false,filer,0)
key_path = re.sub(re_key_path,key_path_new,pub_key,0)
fileread.close()
fileok = open(filename,’w’)
fileok.write(key_path)
fileok.close()
print filename,’替换成功!’
[/python]

cygwin_crt_conf.py

[python]
#!/usr/bin/python
#-*-coding=utf-8-*-

import os,sys,re

crt_conf_dir = ‘/cygdrive/e/CRT_CONF’
global_public_key_true = ‘D:”Use Global Public Key”=00000001’
global_public_key_false = ‘D:”Use Global Public Key”=00000000’
key_path_old = ‘S:”Identity Filename”=’
key_path_new = ‘S:”Identity Filename”=E:\CRT_KEY\identify’

re_global_public_key = re.compile(global_public_key_true,re.DOTALL)
re_key_path = re.compile(‘S:”Identity Filename”=(.*)’)

os.chdir(crt_conf_dir)

c1 = os.walk(os.getcwd())

filelist = []

for c2 in c1:
for c3 in c2[2]:
filelist.append(os.path.join(c2[0],c3))

for filename in filelist:
fileread = open(filename,’r’)
filer = fileread.read()
pub_key = re.sub(re_global_public_key,global_public_key_false,filer,0)
key_path = re.sub(re_key_path,key_path_new,pub_key,0)
fileread.close()
fileok = open(filename,’w’)
fileok.write(key_path)
fileok.close()
print filename,’Replace successful!’
[/python]

主要参考了http://blog.591by.com/show-214-1

telnet on Cygwin

Telnet remote server gives no response on Cygwin

Windows’s telnet doesn’t work on cygwin.We can install inetutils which contains some useful command,such as telnet ftp and so on

inetutils is in Net category.

windows下启动cygwin的cron

windows下启动cygwin的cron
windows 的计划任务管理 taskschedule 实在太不合我口味了,老早以前就搜过 windows 下的 cron 实现,找到一个运行不怎么稳定,莫名其妙的崩溃。老早以前用 cygwin 的时候,以 linux 的思维方式, crontab -e 制定完任务以后,发现怎么也执行不了。

前阵子又进一步了解了 cygwin ,原来还需要启动一个服务才能够搞定 cron 。cygwin 下不仅仅是 cron 需要以 windows 服务的方式启动,消息队列、共享内存以及信号量等进程间通信方式也需要以 windows 服务方式启动 cygserver 以后才可用。除了 cron 包,还需要确认 cygrnsrv 包已经安装:

# 安装 cron 服务
cygrunsrv -I cron -p /usr/sbin/cron -a -D
# 启动服务: 也可以用 windows 的启动方式 net start cron
cygrunsrv -S cron

# 启动 cygserver
cygrunsrv -I cygserver -p /usr/sbin/cygserver -e “CYGWIN=server”

启动 cron 以后,即使关闭 cygwin 命令窗口,crond 还是会继续运行 :) ,而且默认是自动启动的服务,重启机器以后依然运行—不需要开 cygwin 窗口。

如果用于运行cron的用户是有密码的

则需要用

cron-config来进行初始化配置

cygwin中文乱码

直接执行
alias ls=’ls –color –show-control-chars –time-style=long-iso’
或者把上面的内容加到/etc/profile中重启Cygwin即可。

为了使使用更方便,推荐增加如下配置信息:

1. 编辑用户home目录下的文件.inputc,去除以下几行的注释:

set meta-flag on

# 关闭bash命令行8字节字符转义符的转换
set convert-meta off

# 使bash命令行支持8字节字符输出
set output-meta on
set input-meta on

2 编辑用户home目录下的文件.bash_profile,在文件末尾加上下面几行:

alias ls=’ls –color –show-control-chars –time-style=long-iso’
export LC_ALL=zh_CN.GB23122
export LC_CTYPE=zh_CN.GB2312
export LANG=zh_CN.GB2312
export XMODIFIERS=”@im=Chinput”3
stty cs8 -istrip
stty pass8
# Update: 少了这个less就不支持中文了
export LESSCHARSET=latin1

转载自:http://blog.sina.com.cn/s/blog_3ee207aa010008ml.html

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930