0%

如果是初始登陆 GNOME 图形桌面环境,可能会自动启动并为您配置 ssh-agent 程序,具体取决于您本地系统的配置。

如果是在文本控制台上进行登陆,使用 ssh 进行登陆,或者使用 sudosu,可能需要为该会话手动启动 ssh-agent。为此,可以使用以下命令:

1
eval $(ssh-agent)

当运行 ssh-agent 时,它会显示出一些 shell 命令。您需要运行这些命令来设置程序(如 ssh-add)所用的环境变量,以便与它进行通信。eval $(ssh-agent) 命令将启动 ssh-agent 并运行这些命令以自动为该 shell 会话设置这些环境变量。此外,它还显示 ssh-agent 进行的 PID。

How does ssh-agent work?

The eval command tells the shell to run the output of ssh-agent as shell commands; thereafter, processes run by this shell inherit the environment variables and have access to the agent.

Some people express irritation over this seemingly convoluted procedure, and wonder why they can't just run ssh-agent and be done with it. In Unix, there is no way for a process to directly change the environment of other existing processes; it can only change its own environment, and those of child processes it starts. Thus, running ssh-agent cannot affect the environment of the shell which starts it the agent. Having the agent print out shell commands which can be easily executed to set the variables, is as convenient as it gets.

Why eval the output of ssh-agent?

By calling eval you immediately load those variables into your environment.

As to why ssh-agent can't do that itself... Note the word choice. Not "won't", "can't". In Unix, a process can only modify its own environment variables, and pass them on to children. It can not modify its parent process' environment because the system won't allow it. This is pretty basic security design.

在使用 chmod 通过符号法来更改权限时,仅当文件是目录或者已经为用户、组或其他人设置了执行权限时,使用大写的 X 作为权限标志才会添加执行权限。

chmod 命令支持 -R 选项以递归方式对整个目录树中的文件设置权限。在使用 -R 选项时,使用 X 选项以符号形式设置权限会非常有用。这将能够对目录设置执行(搜索)权限,以便在不更改大部分文件权限的情况下,访问这些目录的内容。不过,使用 X 选项时要谨慎,因为如果某个文件设置有任何执行权限,则 X 也将会对该文件设置指定的执行权限。

chmod and the capital X

Suppose you need to change permissions for some directories. Maybe the permissions are too strict, e.g. something like 700 for directories and 600 for files, and you need to give access to some other group and not just the owner.

As you know, execute permission on directories is required for traversal. So you might think doing something like:

chmod -R g+rx /var/somedirectory

This would probably work, but would leave you in a sad state: you'll get the executable bit set on files that are not supposed to be executable at all, which may be just annoying but may get risky as well.

A great alternative is:

chmod -R g+rX /var/somedirectory

The Uppercase X in chmod

I am sure you have already tried, at least once, to set permissions recursively on a directory and all of its contents. I am also sure you have wondered how you could recursively set the executable attribute on the subdirectories, which in this case means “enter”, but not on regular files. Well, this is what uppercase X does.

csongyu/stub-server

Solve the "No response could be served as there are no stub mappings in this WireMock instance." problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>addWiremockFilesOnRootLevel</id>
<phase>package</phase>
<configuration>
<target>
<zip destfile="${project.build.directory}/${project.name}-${project.version}.jar"
update="yes" compress="false">
<zipfileset dir="${project.build.directory}/classes/wiremock" prefix="wiremock"/>
</zip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>