scp构造端口_指定端口号的scp
指定端口號的scp
我正在嘗試將文件從遠程服務器scp到我的本地計算機。 只有80端口可以訪問。
我試過了:
scp -p 80 username@www.myserver.com:/root/file.txt .
但得到了這個錯誤:cp: 80: No such file or directory
如何在scp命令中指定端口號?
One Two Three asked 2018-12-28T21:01:11Z
9個解決方案
1105 votes
與ssh不同,scp使用大寫P開關來設置端口而不是小寫p:
scp -P 80 ... # Use port 80 to bypass the firewall, instead of the scp default
小寫p開關與scp一起用于保存時間和模式。
以下是scp手冊頁的摘錄,其中包含有關兩個開關的所有詳細信息,以及為scp選擇大寫P的原因解釋:
-P port指定要在遠程主機上連接的端口。 請注意,此選項使用大寫“P”編寫,因為-p已經存在?? 保留用于保留rcp(1)中文件的時間和模式。
-p保留原始文件的修改時間,訪問時間和模式。
Michael Goldshteyn answered 2018-12-28T21:01:46Z
45 votes
一個額外的提示。 在scp命令之后放置'-P'選項,無論你正在進入的機器是否是第二個(也就是目的地)。 例:
scp -P 2222 /absolute_path/source-folder/some-file user@example.com:/absolute_path/destination-folder
Gooshan answered 2018-12-28T21:02:09Z
37 votes
你知道什么比man ssh_config更酷嗎? 沒有
如果您多次使用此服務器,請使用以下條目設置/創建man ssh_config文件:
Host www.myserver.com
Port 80
要么
Host myserver myserver80 short any.name.u.want yes_anything well-within-reason
HostName www.myserver.com
Port 80
User username
然后你可以使用:
man ssh_config
要么
man ssh_config
您可以在“主機”行使用ssh,scp,rsync,git和amp; 更多
您可以在配置文件中使用許多配置選項,請參閱:
man ssh_config
Mike answered 2018-12-28T21:03:14Z
24 votes
我正在使用不同的端口然后標準并在文件之間復制文件,如下所示:
scp -P 1234 user@[ip address or host name]:/var/www/mywebsite/dumps/* /var/www/myNewPathOnCurrentLocalMachine
這僅適用于偶爾使用,如果它根據計劃重復,您應該使用rsync和cron job來執行此操作。
Marian Zburlea answered 2018-12-28T21:03:51Z
4 votes
scp help告訴我們端口由大寫字母P指定。
~$ scp
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2
希望這可以幫助。
D D answered 2018-12-28T21:04:20Z
2 votes
復制文件到主機:scp?SourceFile?remoteuser@remotehost:/directory/TargetFile
從主機復制文件:scp?-P?2222?user@host:/directory/SourceFile?TargetFile
從主機復制目錄遞歸:scp?-P?2222?user@host:/directory/SourceFile?TargetFile
注意:如果主機使用端口22以外的端口,你可以用-P選項指定它:scp?-P?2222?user@host:/directory/SourceFile?TargetFile
AJ. answered 2018-12-28T21:05:04Z
1 votes
這可以通過-P開關指定端口來實現:
scp -i ~/keys/yourkey -P2222 file ubuntu@host:/directory/
Vaseem007 answered 2018-12-28T21:05:35Z
0 votes
如果需要將本地文件復制到服務器(指定端口)
scp -P 3838 /the/source/file username@server.com:/destination/file
Turan Zamanl? answered 2018-12-28T21:05:58Z
0 votes
使用scp命令的另一個端口使用大寫P這樣
scp -P port-number source-file/directory user@domain:/destination
你好阿里
Hasan Barary answered 2018-12-28T21:06:27Z
總結
以上是生活随笔為你收集整理的scp构造端口_指定端口号的scp的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python科学计算基础教程pdf下载-
- 下一篇: 红帽RHCA考试内容解析