读书人

OpenSSH for Windows 配备

发布时间: 2012-07-04 19:33:54 作者: rapoo

OpenSSH for Windows 配置

OpenSSH for Windows 配置

???? For both domain and local, it is best to run the command twice (remember to use >>, not >). If you use both, make sure to edit the file to remove any duplicate entires.
?????? mkgroup -l >> ..\etc\group???????? 这是加入本地组的命令。
?????? mkgroup -d >> ..\etc\group?????? 这是加入域组的命令。
???? (注意执行位置的路径)
???? 第三、 将计算机的用户与其密码导入passwd文件中。与上面的组一样,也是分本地和域两种情况。如果没有该文件或没有导入用户的信息。作为server的话,将不能被登陆。
下面是原文:
Use mkpasswd to add authorized users into the passwd file. For local users, use the "-l" switch. For domain users, use the "-d" switch.
???? For both domain and local, it is best to run the command twice (remember to use >>, not >). If you use both, make sure to edit the file to remove any duplicate entires.

?????? mkpasswd -l [-u <username>] >> ..\etc\passwd?????? 这是加入本地用户的命令。
?????? mkpasswd -d [-u <username>] >> ..\etc\passwd?????? 这是加入域用户的命令。

???? NOTE: To add users from a domain that is not the primary domain of the machine, add the domain name after the user name.
???? NOTE: Ommitting the username switch adds ALL users from the machine or domain, including service accounts and the Guest account.

?????? 如果计算机没有域,只要运行两条命令就可以了。(注意我是在openssh/bin目录下运行的。)

改成你自己的/home所在目录,此目录就是默认的登陆目录,比如用户名:Administrator那你进入的目录是 /home/Administrator(注:更改目录后要建立对应的目录,并且用户名的目录也要创建)

mkdir keys\.ssh
cat rsa2048.pub > keys\.ssh\authorized_keys
----------------------
6. 将上面生成私转为SSH客户端可使用格式,这里用PuTTY,可用PuTTYgen转为PuTTY用的PPK格式
----------------------
7. 将OpenSSH设置为只接受密钥认证。
这里额外开了sftp服务。另外,StrictModes no选项将告诉OpenSSH不检查用户ssh的home目录的权限设置
Protocol 2
Port 22
HostKey /etc/ssh_host_rsa_key
PermitRootLogin no
PermitEmptyPasswords no
StrictModes no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#IgnoreUserKnownHosts yes
PasswordAuthentication no
UsePAM no
UsePrivilegeSeparation no
MaxStartups 10:30:60
Subsystem sftp /usr/sbin/sftp-server
----------------------
8. 设置路由器NAT和软件防火墙
NAT设置了映射22号端口的TCP包。
软件防火墙设置允许C:\Program Files\OpenSSH\usr\sbin\sshd.exe侦听TCP port 22。
----------------------
9. 基本上差不多了,要启用或停止OpenSSH服务可
net start opensshd
net stop opensshd
在services.msc里启用或停止也可
----------------------
10. PuTTY作中端还不错,就是中文不好办。
要sftp的话,用WinSCP和FileZilla都行。
WinSCP和FileZilla看及进入中文目录名/文件名都没问题,但拷贝等操作报服务端找不到文件错误,
也许和OpenSSH for Windows带的sftp-server.exe版本低了有关吧(3.x的样子)
注意cygwin环境下将Windows各磁盘映射为/cygdrive/。

读书人网 >windows

热点推荐