小编Sab*_*ina的帖子

Windows SSH:“私钥”的权限太开放

我已经在 Windows 7 中安装了 OpenSSH 7.6 以进行测试。SSH 客户端和服务器工作正常,直到我尝试从此窗口访问我的 AWS EC2 盒之一。

看来我需要更改私钥文件的权限。这可以通过chmod命令在 unix/linux 上轻松完成。

窗户呢?

private-key.ppm 是直接从 AWS 复制的,我猜也是这个权限。

C:\>ssh -V
OpenSSH_7.6p1, LibreSSL 2.5.3

C:\>ver

Microsoft Windows [Version 6.1.7601]

C:\>


C:\>ssh ubuntu@192.168.0.1 -i private-key.ppk
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'private-key.ppk' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "private-key.ppk": bad permissions
ubuntu@192.168.0.1: Permission denied (publickey).

C:\> …
Run Code Online (Sandbox Code Playgroud)

windows ssh openssh permissions private-key

273
推荐指数
9
解决办法
40万
查看次数

Windows 通过 CLI 批量重命名中间文件名?

原始文件

File 15 - Example.txt
File 2 - Example.txt
File 22 - Example.txt
File 3 - Example.txt
File 4 - Example.txt
File 5 - Example.txt
Run Code Online (Sandbox Code Playgroud)

期望输出

File 15 - Example.txt
File 02 - Example.txt
File 22 - Example.txt
File 03 - Example.txt
File 04 - Example.txt
File 05 - Example.txt
Run Code Online (Sandbox Code Playgroud)

单个文件可以很容易地重命名ren

ren "File 2 - Example.txt" "File 02 - Example.txt"
Run Code Online (Sandbox Code Playgroud)

是否可以使用 Windowsrenrename工具对其进行批量重命名?

windows command-line rename batch-file

13
推荐指数
2
解决办法
3359
查看次数

通过 CLI 显示 Windows 的代理设置

有没有办法通过 CLI 准确打印出 Windows 代理设置?

目前,我找到了 2 种方法来做到这一点,不幸的是,当我与 IE Lan 设置 (GUI) 进行比较时,它并不准确。

netsh winhttp show proxy
Run Code Online (Sandbox Code Playgroud)

或者

reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | findstr "ProxyServer AutoConfigURL"
Run Code Online (Sandbox Code Playgroud)

示例 1

C:\>netsh winhttp show proxy

Current WinHTTP proxy settings:

    Proxy Server(s) :  x.x.x.x:8080
    Bypass List     :  (none)


C:\>
Run Code Online (Sandbox Code Playgroud)

示例 2

C:\>reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | findstr "ProxyServer AutoConfigURL"
    ProxyServer    REG_SZ    http=127.0.0.1:8888;https=127.0.0.1:8888
    AutoConfigURL    REG_SZ    http://myproxyserver/wpad.dat

C:\>
Run Code Online (Sandbox Code Playgroud)

实际设置

在此处输入图片说明

proxy command-line

6
推荐指数
1
解决办法
2万
查看次数

Windows 相当于 Linux 的“cat -n”?

在 Linux 中,我可以使用命令轻松查看旁边有行号的任何文件cat -n

sh-4.4$ cat test   
line 1             
line 2             
line 3             
sh-4.4$ 

sh-4.4$ cat test -n
     1  line 1     
     2  line 2     
     3  line 3     
sh-4.4$ 
Run Code Online (Sandbox Code Playgroud)

那么 Windows 呢?是否有类似的命令产生类似的输出?

type是查看文件内容的 Windows 命令之一。

C:\>type test.txt
line 1
line 2
line 3
C:\>
Run Code Online (Sandbox Code Playgroud)

然而,其中没有任何-n选项。

C:\>type /?
Displays the contents of a text file or files.

TYPE [drive:][path]filename

C:\>
Run Code Online (Sandbox Code Playgroud)

这就是我在 Windows 中所期待的

C:\>(windows command to view and print line number) test.txt
     1  line 1     
     2  line …
Run Code Online (Sandbox Code Playgroud)

command-line window

5
推荐指数
1
解决办法
2万
查看次数

如何在 CLI 中显示当前的 Windows 操作系统日期、时间和时区?

在 Linux 中,可以使用date命令轻松完成打印日期、时间和时区

[user@linux ~]$ date
Sun Mar 10 11:51:55 -04 2018
[user@linux ~]$ 
Run Code Online (Sandbox Code Playgroud)

-4 之前在时间之后和年份之前代表时区(-4)。

这是在 Python ....

[user@linux ~]$ python
Python 2.7.5 (default, May  3 2017, 07:55:04) 
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import time
>>> print (time.strftime("\n Date: %d %B %Y, %H:%M:%S %Z\n"))

 Date: 11 March 2018, 00:05:50 EST

>>> 
Run Code Online (Sandbox Code Playgroud)

我想知道如何使用本机 windows 命令在 Windows 操作系统上执行相同的操作?

echo %date%-%time%命令只能产生天、日期、段时间。但是时区不存在。

C:\> echo  %date%-%time%
 Sun 03/10/2018-11:56:05.31

C:\>
Run Code Online (Sandbox Code Playgroud)

我期待的是这样的。

C:\> <some windows command>
 Sun …
Run Code Online (Sandbox Code Playgroud)

window

4
推荐指数
1
解决办法
3万
查看次数