大网数据广告活动
服务器运维问答

Is it possible to set that path of the scp command to use by OpenSSH sshd daemon?

· 52CE 我爱测

I have a curious problem with OpenSSH in SLES 12 SP4 Linux servers. We install a customized OpenSSH on ourservers, so in each machine we have two versions of OpenSSH, the official package of the operating system and the one that …

问题原文

原帖链接 · Ciges · CC BY-SA 4.0

I have a curious problem with OpenSSH in SLES 12 SP4 Linux servers.

We install a customized OpenSSH on ourservers, so in each machine we have two versions of OpenSSH, the official package of the operating system and the one that we have compiled.

For the case of SLES 12 SP4 if we run the following command from another server

scp -r directory/. destination_server:/path/to/directory

the following error arises

scp: error: unexpected filename: .

We have verified that the problem is with the scp binary under /usr/bin/scp, which is run by our OpenSSH instead of its scp under its own path.

After searching and testing the solution applied is to remove the execution rights on /usr/bin/scp, so our version of OpenSSH can not use it, and the scp -r from the client works perfectly.

Is there a more elegant to way to tell to the daemon to use the scp binary under its own path instead of /usr/bin/scp?

Best regards

社区高分解答

原帖链接 · Lacek · CC BY-SA 4.0

It isn't the SSH daemon which uses the scp program directly, so no, you can't reconfigure it to use another binary. You need to remove all but the "right" scp binaries from the system, or rewrite the PATH environmental variable (preferably in the system default profile), because from the viewpoint of the SSH daemon, scp is just a wrapper for running a remote command.

Basically, here is what scp does:

  1. Initiates the connection through ssh
  2. Sends the scp -t (target path) command through the channel, as if you used the ssh user@target scp -t /this/file command.
  3. Sends the access mode and the file length, ending with '\n'.
  4. Sends the file contents through the SSH channel.

You can emulate scp with the following commands:

ssh user@host scp -t /tmp/aFile.to.create
(enter your password)
C0664 41 originalFileName
The file should contain
these two lines.
(press enter twice)

The third line contains the access rights, the file size, and the original file name. And since the scp command sent "as is", it is up to the target system to find that program for the user.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。