我正在尝试使用非常基本的 scp 命令将文件从本地系统上的虚拟机 (Ubuntu 18.04) 移动到远程服务器。此问题仅出现在一台特定服务器上,其他服务器运行正常,因此这不是普遍现象。
scp <file name> <user>@<complete_hostname>:~/
但是这个命令不会在身份验证成功之后继续进行。
SCP Log: (from local machine, Ubuntu 18.04)
==========
debug1: Next authentication method: publickey
debug1: Offering public key:
RSA SHA256:<key> /home/username/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 'HOSTNAME' ([10.6.26.145]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_IN
debug1: Sending command: scp -v -r -d -t ~/received/
Form another remote server:
debug1: Next authentication method: publickey
debug1: Trying private key: /home/username/.ssh/identity
debug1: Offering public key: /home/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/username/.ssh/id_dsa
debug1: Trying private key: /home/username/.ssh/id_ecdsa
debug1: Next authentication method: password
username@hostname's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = C
debug1: Sending env LC_ALL = C
debug1: Sending command: scp -v -t ~/
我没有这些机器的任何特权访问权限,有没有办法找出问题所在?我需要做什么才能做到同样的事情?
答案1
对于我来说,我要访问的目录scp
不存在。
我试图将文件发送到C:\Users\MyUser\AppData\AnotherDir\AnotherDir\
。一旦我将目标目录更改为C:\Users\MyUser\
,它就成功了。
答案2
对于未来的读者,
# This will use port 2222
scp -v -P 2222 ~/local_file.txt admin@remote:~/dest
但
# This will use default port 22 and ignore your 2222
scp -v ~/local_file.txt -P 2222 admin@remote:~/dest
因此scp
似乎以这种方式挂起(错误端口)。-v
标志是你的朋友。
答案3
原来是防火墙阻止了传输。原因是我的默认 shell 上的文件权限.*rc文件。
我的默认 shell 是 csh,文件权限是
-rwxr-s---
将这些更改为
-rw-r-----
解决了这个问题。