添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
修改x86/x86_64源、xz压缩包支持、sha512sum的apt-cyg: apt-cyg #wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg wget http://xstarcd.github.io/wiki/files/shell/apt-cyg -O /usr/local/bin/apt-cyg chmod +x /usr/local/bin/apt-cyg apt-cyg --help cygcheck --help # 修改软件源 #apt-cyg --mirror http://mirrors.163.com/cygwin #apt-cyg --mirror http://mirrors.aliyun.com/cygwin apt-cyg --mirror https://mirrors.kernel.org/sourceware/cygwin/ # ftp://mirror.mcs.anl.gov/pub/cygwin # http://mirrors.163.com/cygwin # ftp://ftp.ges.redhat.com/private/releng/cygwin-1.8 201308后Cygwin版本变更,需修改apt-cyg 软件源路径变更 2013-08-08后Cygwin分为x86、x86_64两个安装包,源路径也改不同路径(x86、x86_64),因此apt-cyg下载setup.bz2和setup.ini时发生404错误。 在apt-cyg增加MPath来支持x86、x86_64版本。 添加xz压缩包支持:修改apt-cyg根据包文件扩展名选择binzip2或xz来进行解压。 cygwin 2.0.0中改用sha512sum替代md5校验,执行报 cygwin64 MD5 sum did not match, exiting 错误 修改apt-cyg,将md5sum 换成 sha512sum # apt-cyg install man cygwin-doc apt-cyg install vim screen tmux wget subversion openssh pwgen gzip bzip3 curl rsync bash-completion \ lftp nc tree p7zip connect-proxy util-linux bind-utils inetutils

安装python环境

apt-cyg install python python-crypto 参考: http://atbrox.com/2009/09/21/how-to-get-pipvirtualenvfabric-working-on-cygwin/ #wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg #sh setuptools-0.6c11-py2.6.egg apt-cyg install python-setuptools easy_install pip pip install pssh # ansible apt-cyg python-crypto pip install ansible #pip install moin 背景颜色:(RGB)0,40,51;或11,22,33(就是这个Wiki页面的背景色) 字体颜色:(RGB)31,148,150(较暗);或191,191,191 目录颜色:(RGB)255,128,128 压缩文件颜色:(RGB)128,128,0 字体:Consolas,Courier New,Fixedsys,YaHei Consolas hybrid YaHei Consolas hybrid.1.12字体下载: YaHei.Consolas.1.12.7z 百度网盘下载:YaHei.Consolas.1.12.7z alias grep='grep --color' # show differences in colour alias egrep='egrep --color=auto' # show differences in colour alias fgrep='fgrep --color=auto' # show differences in colour alias ls='ls -hF --color=tty' # classify files in colour alias ll='ls -la' # long list alias la='ls -A' # all but . and .. alias l='ls -CF' # # 关闭ControlMaster auto,避免ssh连接时因不支持unix-socket报如下错误问题: # mm_receive_fd: no message header # process_mux_new_session: failed to receive fd 0 from slave alias ssh="ssh -S none" # 将常用Windows命令输出转换为utf8,解决Windows自有命令显示乱码问题 _runiconv () { _cmd=$1;shift;$_cmd $* 2>&1|iconv -f gbk -t utf8; } alias ping='_runiconv ping' alias ifconfig='_runiconv ipconfig' alias netstat='_runiconv netstat' alias tracert='_runiconv tracert' alias route='_runiconv route' #在使用screen过程中,经常会遇到“闪屏”的问题,这是可以关掉的。 #快速关掉:也就是先输入CTRL + a,再输入CTRL + g。 #永久关闭:修改/etc/screenrc 加入 vbell off # prefix key (Ctrl+a) set -g prefix ^a #set -g prefix C-a unbind ^b #unbind C-b bind a send-prefix # prefix key (Ctrl+a) # split window unbind '"' unbind % bind - splitw -v # vertical split (prefix -) bind | splitw -h # horizontal split (prefix |) # select pane bind k selectp -U # above (prefix k) bind-key k select-pane -U bind j selectp -D # below (prefix j) bind h selectp -L # left (prefix h) bind l selectp -R # right (prefix l) # copy mode # enter copy mode (prefix Escape) bind Escape copy-mode # paste buffer (prefix Ctrl+p) bind ^p pasteb #bind-key -T copy-mode C-Space send-keys -X begin-selection # reload config (prefix r) bind r source ~/.tmux.conf \; display "Configuration reloaded!" #-- statusbar --# set -g status-interval 1 set -g status-keys vi setw -g mode-keys vi setw -g automatic-rename off #set-option -g status-style bg=cyan # statusbar #set-window-option -g window-status-current-style fg=colour166,bg=#c0c0c0 set-window-option -g window-status-current-style fg=colour166,bg=colour222 set fileformats=unix,dos,mac set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 set encoding=utf-8 " set termencoding=cp936 let &termencoding = &encoding language messages en_US.UTF-8 "language messages zh_CN.UTF-8 " colo murphy " tab set tabstop=4 set cindent shiftwidth=4 set autoindent shiftwidth=4 " TAB -> Space set expandtab

~/.ssh/config

#ssh_config #~/.ssh/config IdentitiesOnly yes ServerAliveInterval 60 GSSAPIAuthentication no Host m* Port 22 User root ControlMaster auto ControlPath ~/.ssh/master-%r@%h:%p #ProxyCommand connect-proxy -S 127.0.0.1:2223 %h %p Host mNagios Hostname 172.16.16.150 chmod og+w /tmp touch /var/log/sshd.log chown system:system /var/log/sshd.log /var/empty /etc/ssh_h* chmod 755 /var/empty Cygwin設定OpenSSH: ssh-host-config Should privilege separation be used? (yes/no) :yes Should this script create a local user 'sshd' on this machine? (yes/no) :yes Do you want to install sshd as service? (yes/no) :yes Default is "ntsec" . CYGWIN=ntsec tty 启动OpenSSH:net start sshd cygrunsrv -S sshd 停止OpenSSH:net stop sshd

nontsec

这在 Cygwin 下创建的文件,其他管理员不可写,是所谓的 ntsec 在起作用。通过 NTFS 的权限设置,模拟 UNIX 的权限。可以通过 CYGWIN 环境变量修改。如: export CYGWIN="nontsec nosmbntsec"

中文乱码设置

** 若存在中文问题才进行以下设置。 ** # Redhat Cygwin中未做以下设置,中文正常 alias ls='ls --color --show-control-chars' # git log修改这个设置后可显示中文commit log #export LESSCHARSET=latin1 export LESSCHARSET=UTF-8 alias less='/bin/less -r' #export LC_ALL=zh_CN.UTF-8 #export LC_CTYPE=zh_CN.UTF-8 #export LANG=zh_CN.UTF-8 #export OUTPUT_CHARSET="GBK" #stty cs8 -istrip #stty pass8 export CYGWIN="nontsec nosmbntsec" http://stackoverflow.com/questions/9300722/cygwin-error-bash-fork-retry-resource-temporarily-unavailable http://cygwin.wikia.com/wiki/Rebaseall -bash-4.1$ wc m1.txt 3 [main] bash 2216 child_info_fork::abort: data segment start: parent(0x26D000) != child(0x38D000) -bash: fork: retry: Resource temporarily unavailable 2013930 4027950 74968256 m1.txt rkosegi's Answer seems to be working for everyone (myself included). But, just so you don't have to follow the daisy chain of links: (assuming Cygwin is installed at C:\cygwin): 1.Open Task Manager and close any processes that look to be Cygwin related. 2.Open C:\Cygwin\bin in Windows Explorer 3.Verify that dash.exe, ash.exe, rebase.exe, and rebaseall exist in this folder - If any of them are missing, re-run Cygwin setup and select the dash, ash, and rebase packages 4.right-click your C:\Cygwin folder, uncheck Read-only (if its checked), and press OK. - When an error about not being able to switch some files comes up, select "Ignore All". Wait for this process to complete. 5.Browse to C:\Cygwin\bin in Windows Explorer 6.Right click dash.exe and click "Run as Administrator". A command Prompt should appear with nothing but a $ 7.Type /usr/bin/rebaseall -v, hit enter, and wait for the process to complete. - If you get errors about Cygwin processes running, try Step 1 again. If that still doesn't work, Restart your computer into safe mode and try these steps again. 8.Try opening Cygwin again. This process worked for me. I hope it works for you guys too. Source: http://cygwin.wikia.com/wiki/Rebaseall ssh-agent.exe -s SSH_AUTH_SOCK=/tmp/ssh-GYP4AmeZ5LP6/agent.1272; export SSH_AUTH_SOCK; SSH_AGENT_PID=4536; export SSH_AGENT_PID; echo Agent pid 4536; SSH_ENV=$HOME/.ssh/ssh-agent-env function stop_ssh_agent { if [ $(ps -ef|grep mintty$|wc -l) -lt 2 -a -n "$SSH_AGENT_PID" ];then ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null && kill $SSH_AGENT_PID function start_ssh_agent { if [ -f "${SSH_ENV}" ]; then . ${SSH_ENV} > /dev/null ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null && return 0 echo "Initialising new SSH agent..." /usr/bin/ssh-agent -s | sed 's/^echo/#echo/' > ${SSH_ENV} \ && echo succeeded \ && chmod 600 ${SSH_ENV} \ && . ${SSH_ENV} > /dev/null #&& /usr/bin/ssh-add \ start_ssh_agent #trap "[ \$(ps -ef|grep mintty\$|wc -l) -lt 2 ] && kill $SSH_AGENT_PID" 0 trap "stop_ssh_agent" 0 MAC OS版本 # start_stop_ssh_agent SSH_ENV=$HOME/.ssh/ssh-agent-env function stop_ssh_agent { U=$(whoami) if [ $(ps aux|grep "$U.*-bash\$"|grep -v grep|wc -l) -lt 3 -a -n "$SSH_AGENT_PID" ];then ps aux | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null && kill $SSH_AGENT_PID function start_ssh_agent { if [ -f "${SSH_ENV}" ]; then . ${SSH_ENV} > /dev/null ps aux | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null && return 0 echo "Initialising new SSH agent..." /usr/bin/ssh-agent -s | sed 's/^echo/#echo/' > ${SSH_ENV} \ && echo succeeded \ && chmod 600 ${SSH_ENV} \ && . ${SSH_ENV} > /dev/null #&& /usr/bin/ssh-add \ start_ssh_agent trap "stop_ssh_agent" 0 sdesc: "Key manager for OpenSSH" ldesc: "Keychain is an OpenSSH key manager, typically run from ~/.bash_profile. When keychain is run, it checks for a running ssh-agent, otherwise it starts one. It saves the ssh-agent environment variables to ~/.keychain/$HOSTNAME-sh, so that subsequent logins and non-interactive shells such as cron jobs can source the file and make passwordless ssh connections. In addition, when keychain runs, it verifies that the key files specified on the command-line are known to ssh-agent, otherwise it loads them, prompting you for a password if necessary" ~/.bash_profile: eval `keychain --eval --agents ssh id_dsa` 在 Windows Terminal 中使用 Cygwin 命令行或 Git Bash: https://leo3418.github.io/zh/2020/05/24/cygwin-git-bash-in-wt.html 安装Windows Terminal:在Microsoft Store搜索“Terminal”安装(不要安装Preview版本)。 Windows 终端提示与技巧: https://learn.microsoft.com/zh-cn/windows/terminal/tips-and-tricks Windows Terminal配置文件说明: https://learn.microsoft.com/zh-cn/windows/terminal/customize-settings/startup#default-terminal-application 在Windows Terminal中设置Cygwin: 设置->添加新配置文件: 命令行方式一: C:\cygwin64\bin\bash.exe -i -l 命令行方式二: C:\cygwin64\Cygwin.bat bash在登录状态才会加载profile、bashrc,需要使用 -i -l 参数,启动命令行: 删除crtl+v、ctrl+c热键设置:设置->操作中删除(终端中需要使用这两个组合键)。 开启鼠标右键菜单(不开启右键直接为粘贴) 按住Shift键单击下拉菜单中的设置,会用编辑器打开settings.json文件,在profiles->deflaults中添加 "experimental.rightClickContextMenu": true : "profiles": "defaults": { "experimental.rightClickContextMenu": true, - 按住 Alt 并单击下拉菜单中的“设置”按钮,查看默认设置 多标签页、多标签页、多标签页,重要事情说3遍,并且支持多种布局方式; 不同标签页独立配置Task,也就是运行不同的命令行程序,特别是shell,Task支持名字分组和分配快捷键; 界面现代化,有标签页、快捷菜单、控制台区、状态栏、滚动条; 支持连接到多种类型命令行程序环境,Cygwin、msys、WSL都不在话下; 图形化配置方式,每一部分都支持个性化配置,所有配置项保存到文件ConEmu.xml; 支持集成到其他程序界面中,比如文件管理器Explorer; 支持字符加粗、斜体、下划线、闪烁、前后景色等风格; 全面支持Unicode,支持ANSI X3.64标准和xterm256色; 附带字符界面的文本管理器Far Manager及其插件; 能运行在Windows 2000及以上版本的Windows系统,开箱即用。

脚本添加ssh主机名自动完成

/etc/bash_completion.d/ssh _ssh() local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-) COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) return 0 complete -F _ssh ssh