GVKun编程网logo

Cygwin 下用 Open SSH 启动 SSH 服务(windows open ssh)

23

以上就是给各位分享Cygwin下用OpenSSH启动SSH服务,其中也会对windowsopenssh进行解释,同时本文还将给你拓展(ConEmuCygwin)如何在cygwinbash脚本中更改Co

以上就是给各位分享Cygwin 下用 Open SSH 启动 SSH 服务,其中也会对windows open ssh进行解释,同时本文还将给你拓展(ConEmu Cygwin)如何在cygwin bash脚本中更改ConEmu的选项卡名称、Bash Shell;读命令;在Windows 7上使用Cygwin、bash – Cygwin启动脚本、bash – 从Windows桌面的cygwin ssh快捷方式等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

Cygwin 下用 Open SSH 启动 SSH 服务(windows open ssh)

Cygwin 下用 Open SSH 启动 SSH 服务(windows open ssh)

【删除原服务

如果前面已经建立过服务,但是需要重新启用服务的需要删除服务:

services.msc 中可以看 cygwin sshd 的属性发现服务名为 sshd

cmd 进入命令行,然后 sc delete sshd,屏幕上出现 [SC] DeleteService SUCCESS,

本质上相当于删除 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet 下的注册表项

进入 services.msc 发现服务已删除 

【建立新服务

然后进入 cygwin 建立 ssh 服务:

1) 修改环境变量 PATH 变量中加入 Cygwin 路径 添加 CYGWIN 变量设为 ntsec tty

2) 授权:

使用 windows 用户的密码和用户组 

$mkpasswd -l > /etc/passwd 

$mkgroup -l > /etc/group      

Note:   设置文件权限 (如果 win7 需要先以管理员权限运行 cygwin 才能使用 chmod), 在域用户的时候理论上要加 - d,但是经过测试没用,还是用上面的命令,配置好 service 之后直接连接 127.0.0.1 然后输入用户名即可,不需要其他密码之类的信息就可以本地 ssh 登录了

$chmod +r /etc/group
$chmod +r /etc/passwd
$chmod +rwx /var

3) 安装:

ssh-host-config 

*** Info: Generating /etc/ssh_host_key

*** Info: Generating /etc/ssh_host_rsa_key

*** Info: Generating /etc/ssh_host_dsa_key

*** Info: Creating default /etc/ssh_config file

*** Info: Creating default /etc/sshd_config file

*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.

*** Info: However, this requires a non-privileged account called ''sshd''.

*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ

ME.privsep.

*** Query: Should privilege separation be used? (yes/no) yes  #输入 yes

*** Info: Updating /etc/sshd_config file

 

 

*** Warning: The following functions require administrator privileges!

 

*** Query: Do you want to install sshd as a service?

*** Query: (Say "no" if it is already installed as a service) (yes/no) yes  #输入 yes

*** Info: Note that the CYGWIN variable must contain at least "ntsec"

*** Info: for sshd to be able to change user context without password.

*** Query: Enter the value of CYGWIN for the daemon: [ntsec] ntsec  #输入 ntsec

*** 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: You appear to be running Windows 2003 Server or later.  On 2003 and

*** Info: later systems, it''s not possible to use the LocalSystem account

*** Info: for services that can change the user id without an explicit password

*** Info: (such as passwordless logins [e.g. public key authentication] via sshd). 

*** Info: If you want to enable that functionality, it''s required to create a new

*** Info: account with special privileges (unless a similar account already exists).

*** Info: This account is then used to run these special servers.

*** Info: Note that creating a new user requires that the current account have

*** Info: 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) no  #输入 no,不指定启动用户

*** Query: Create new privileged user account ''cyg_server''? (yes/no) no  #输入 no,不指定启动用户

*** ERROR: There was a serious problem creating a privileged user.

*** Query: Do you want to proceed anyway? (yes/no) yes  #输入 yes

*** Warning: Expected privileged user ''cyg_server'' does not exist.

*** Warning: Defaulting to ''SYSTEM''

 

*** Info: The sshd service has been installed under the LocalSystem

*** Info: account (also known as SYSTEM). To start the service now, call

*** Info: `net start sshd'' or `cygrunsrv -S sshd''.  Otherwise, it

*** Info: will start automatically after the next reboot.

 

*** Info: Host configuration finished. Have fun!

 

4) Windows 下或者在 cygwin 窗口中直接 net start sshd  (sshd 即为新建的服务,services.msc 中的 Cygwin SSHD)

plus) 如果启用服务有问题可以尝试操作:

$ mkpasswd -l > /etc/passwd
$ mkgroup -l > /etc/group
$ cygrunsrv -R sshd
$ ssh-host-config -y
$ cygrunsrv -S sshd



(ConEmu Cygwin)如何在cygwin bash脚本中更改ConEmu的选项卡名称

(ConEmu Cygwin)如何在cygwin bash脚本中更改ConEmu的选项卡名称

我正在配置我的ConEmu Cygwin环境.我创建了一个任务,当我在一个选项卡中启动它时,任务将运行一个批处理文件,这反过来会将dir更改为cygwin并运行
bash --login -i my_ssh_entry_script.sh

在my_ssh_entry_script.sh中,它将读取我的主目录中的配置文件,然后打印一个菜单供我选择要连接的主机.最后

...
exec ssh -p$port $userhost

现在我可以在同一个conemu选项卡中处理选定的机器.这很好用.而且脚本也适用于linux机器.

但是有一点缺陷.我无法更改标签的标题.我试图将其更改为:

....
exec $(cygpath ${ConEmuDir})/ConEmu.exe /cmd ssh -p$port $userhost -cur_console:t:$title

但这将始终创建一个新选项卡.有什么建议可以解决它吗?谢谢〜

1)您需要GuiMacro,在项目维基中进行了详细描述:
http://conemu.github.io/en/GuiMacro.html
ConEmuC -GuiMacro Rename 0 "Title"

2)您不需要运行批处理.它会在您的进程树中导致额外且无用的cmd.exe.您可以直接从任务内容中执行所有必需的“CD”和“SET”.

Bash Shell;读命令;在Windows 7上使用Cygwin

Bash Shell;读命令;在Windows 7上使用Cygwin

好的,所以我遇到了这个问题.我在 Windows上编写了一个在cygwin中运行的脚本.我已经尝试了一堆基本的示例脚本,以防它是我的脚本问题.

所以我尝试了这个:

#!/bin/bash
echo -e "Enter your name and press [ENTER]: \c" 
read var_name
echo "Your name is: $var_name"

然后我将运行它并输入var_name的名称.

我明白了:

$./project1.sh
Enter your name and press [ENTER]: Jake
': not a valid identifierad: `var_name
Your name is:

据我所知,我遇到了阅读问题.我正在尝试为我的课程开展一个项目,但我似乎无法弄清楚为什么它不会读它.我毫不夸张地跟着这本书,然后在网上使用这些似乎对我不起作用的例子.有没有人知道这是我的设置还是我错过了什么,谢谢.

你应该对该脚本执行od -xcb.我的猜测是,它几乎肯定会有错误的行结束字符.

我建议这是因为该行:

': not a valid identifierad: `var_name

看起来像两条线一样可疑:

.........................ad: `var_name
': not a valid identifier

合并在一起(.字符表示已被覆盖的内容).

如果你在该行中的变量是var_namecarriage-return而不是更正常的var_name,那就是这种情况.

事实上它是Cygwin也指出了这个结论,因为当你使用Windows编辑器编辑你的脚本时经常遇到麻烦,这个编辑器使用CR / LF,其中Cygwin只需要LF.

我怀疑你会发现在你的实际脚本上做一个od -xcb表明你在一个或多个脚本行上有那些Windows行结尾.

事实上,我刚刚在Ubuntu下通过在读取行的末尾放置一个CTRL-M并输出(稍微修改以显示CTRL-M)来测试它:

pax@pax-desktop:~$od -xcb qq.sh ; ./qq.sh

0000000    2123    622f    6e69    622f    7361    0a68    6365    6f68
          #   !   /   b   i   n   /   b   a   s   h  \n   e   c   h   o
        043 041 057 142 151 156 057 142 141 163 150 012 145 143 150 157
0000020    2d20    2065    4522    746e    7265    7920    756f    2072
              -   e       "   E   n   t   e   r       y   o   u   r    
        040 055 145 040 042 105 156 164 145 162 040 171 157 165 162 040
0000040    616e    656d    6120    646e    7020    6572    7373    5b20
          n   a   m   e       a   n   d       p   r   e   s   s       [
        156 141 155 145 040 141 156 144 040 160 162 145 163 163 040 133
0000060    4e45    4554    5d52    203a    635c    2022    720a    6165
          E   N   T   E   R   ]   :       \   c   "      \n   r   e   a
        105 116 124 105 122 135 072 040 134 143 042 040 012 162 145 141
0000100    2064    6176    5f72    616e    656d    0a0d    6365    6f68
          d       v   a   r   _   n   a   m   e  \r  \n   e   c   h   o
                                                 ^^

        144 040 166 141 162 137 156 141 155 145 015 012 145 143 150 157
0000120    2220    6f59    7275    6e20    6d61    2065    7369    203a
              "   Y   o   u   r       n   a   m   e       i   s   :    
        040 042 131 157 165 162 040 156 141 155 145 040 151 163 072 040
0000140    7624    7261    6e5f    6d61    2265    0a0a
          $  v   a   r   _   n   a   m   e   "  \n  \n
        044 166 141 162 137 156 141 155 145 042 012 012
0000154

Enter your name and press [ENTER]: pax
': not a valid identifierar_name
Your name is:

换句话说,与您所看到的非常相似.

顺便说一句(现在我可以访问我的Cygwin环境),你看到的是输出:

abcdefghij.sh: line 99 read: `var_name
`: not a valid identifier

第二行覆盖第一行,给出:

`: not a valid identifierad: `var_name

换句话说,奇怪的单词identifyierad实际上由标识符和最终广告组成:来自:之所以与上面的例子相似(而不是精确)是因为你的文件名和行号与我的小测试脚本不同.

bash – Cygwin启动脚本

bash – Cygwin启动脚本

启动后,如何在cygwin中运行脚本?

我想要自动添加一些挂载,并在启动时运行cygwin中的其他脚本.我看到在linux中,就像在etc / init.d中添加一个shell文件一样简单
但是,我尝试添加这个目录和chmod x添加一个shell,chmod这个shell文件,但是不起作用.

另外,如果有一种方法来运行脚本,如关闭umount,rmdir等.

你正在寻找的是
~/.bash_profile

AKA

C:\cygwin\home\CPJ\.bash_profile

有了库存安装,这个文件是在Cygwin启动时读取的.如果你想添加更多的文件,你可以编辑.bash_profile文件

source foo.sh
source bar.sh
source baz.sh

Bash man page

bash – 从Windows桌面的cygwin ssh快捷方式

bash – 从Windows桌面的cygwin ssh快捷方式

我有多台服务器需要远程访问.
我喜欢Cygwin对Putty这样做.

无论如何 – 打开我很酷的Mintty窗口,然后输入以下命令的过程需要太长时间.
PS – 我正在对这些服务器使用“密钥”身份验证.

首先,我从Windows桌面双击Cygwin Terminal快捷方式.

然后一旦终端会话启动,从命令提示符输入以下内容 –

$eval `ssh-agent`
$ssh-add
$ssh <username>@<servername>

请记住,我的’servername’是可变的.其实我有大约10个不同的服务器名称可能会被插入到那里 – 因此我需要10个不同的快捷方式.我更喜欢双击我的桌面上的东西,这将启动我的Mintty,并自动执行上述bash shell命令.

有人有或可以推荐一个漂亮/优雅的解决方案来做到这一点吗?

(我有一种感觉,它与我点击的Windows快捷方式图标的Target属性有关.)

你可以做到这一点没有太多的困难.复制现有的Cygwin终端图标,右键单击它,然后选择属性.您应该在目标字段中看到如下所示的内容:
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -

将其替换为以下内容(替换为< username>和< servername>相关):

C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/bash -l -c "eval `ssh-agent` ; ssh-add ; ssh <username>@<servername>"

根据需要重复其他服务器.而已!

(详细信息:我们用显式调用bash替换参数[这意味着使用标准登录shell]来运行命令-l部分意味着使用登录shell,特别是您的PATH变量设置所以bash可以找到ssh.-c部分只是介绍你应该从你的问题中识别的命令.)

关于Cygwin 下用 Open SSH 启动 SSH 服务windows open ssh的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于(ConEmu Cygwin)如何在cygwin bash脚本中更改ConEmu的选项卡名称、Bash Shell;读命令;在Windows 7上使用Cygwin、bash – Cygwin启动脚本、bash – 从Windows桌面的cygwin ssh快捷方式等相关内容,可以在本站寻找。

本文标签: