海运的博客

Windows/Cygwin下安装配置SSH服务器

发布时间:December 5, 2012 // 分类:Cygwin // No Comments

1.Cygwin安装OpenSSH,可使用apt-cyg包管理器快速安装。

apt-cyg install openssh

配置OpenSSH服务,以管理员运行Cygwin Terminal。

$ ssh-host-config
*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Generating /etc/ssh_host_ecdsa_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/README.privsep.
*** Query: Should privilege separation be used? (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: [] ssh
*** 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 XP 64bit, Windows 2003 Server,
*** Info: or later.  On these systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar 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: ssh
*** Query: Reenter: ssh

*** Query: Create new privileged user account 'ssh'? (yes/no) yes
*** Info: Please enter a password for new user ssh.  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 'ssh' has been created with password 'passwd'.
*** 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 'ssh' account.

*** Info: Also keep in mind that the user 'ssh' needs read permissions
*** Info: on all users' relevant files for the services running as 'ssh'.
*** Info: In particular, for the sshd server all users' .ssh/authorized_keys
*** Info: files must have appropriate permissions to allow public key
*** Info: authentication. (Re-)running ssh-user-config for each user will set
*** Info: these permissions correctly. [Similar restrictions apply, for
*** Info: instance, for .rhosts files if the rshd server is running, etc].


*** Info: The sshd service has been installed under the 'ssh'
*** 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!

启动SSH服务:

cygrunsrv -S sshd

SSH常用命令妙用

发布时间:July 2, 2012 // 分类:常用软件,Linux基础 // No Comments

之前有介绍Putty工具Plink应用,Linux下ssh同样可实现很多妙用。
1.动态socks5端口转发,可用于代**理上网

ssh -NfD 0.0.0.0:7070 root@haiyun.me
-D #动态转发端口

2.转发本地端口到远程服务器:

#转发本机8080端口到google.com 80端口
ssh -N -f -L <0.0.0.0>:8080:google.com:80 root@haiyun.me
-N #仅转发端口,不执行命令
-f #后台运行
-L #监听地址端口,-L [bind_address:]port:host:hostport

3.转发远程服务器端口到本地端口,远程服务器监听指定地址查看:https://www.haiyun.me/archives/1010.html

ssh -N -f -R 0.0.0.0:8080:localhost:80 root@haiyun.me
#转发远程服务器8080端口到本地80端口

4.登录服务器并执行文本内的命令:

ssh user@server "`cat test.txt`"

5.测试两台服务器的带宽:

yes | pv | ssh user@server "cat > /dev/null"

6.登录到远程服务器screen窗口,如断开、连接不受影响。

ssh -t user@server /usr/bin/screen -xRR
分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...