• 请不要在回答技术问题时复制粘贴 AI 生成的内容
itfanr
V2EX  ›  程序员

SSH 远程登陆主机,如何上传大量代码?

  •  
  •   itfanr ·
    itfanr · Feb 13, 2014 · 7511 views
    This topic created in 4654 days ago, the information mentioned may be changed or developed.
    如果本地是windows,远程主机是linux。本地网站测试好了,该怎么上传到远程主机呢?谢谢
    50 replies  •  1970-01-01 08:00:00 +08:00
    Keyes
    Keyes
    Feb 13, 2014❤️2
    1
    sftp
    sarices
    sarices
    Feb 13, 2014
    2
    sftp
    sarices
    sarices
    Feb 13, 2014
    3
    我是sarices
    sarices
    sarices
    Feb 13, 2014
    4
    @livid 出现BUG了,一楼是我发的
    dreasky
    dreasky
    Feb 13, 2014
    5
    git
    sarices
    sarices
    Feb 13, 2014
    6
    @livid 看针对这个主题的扣费,我扣了4次,包括这次
    itfanr
    itfanr
    OP
    Feb 13, 2014
    7
    @Keyes
    @sarices sftp 听说过。我可不可以放在云存储(设好下载密码),然后远程下载&解压?
    itfanr
    itfanr
    OP
    Feb 13, 2014
    8
    @sarices 为什么你是一楼?
    vfasky
    vfasky
    Feb 13, 2014❤️1
    9
    在本地终端执行:
    scp -P [ssh端口] -r [文件夹路径] [ssh user]@[ssh 域名]:[服务端路径]
    sarices
    sarices
    Feb 13, 2014
    10
    @itfanr 可以的,只要有一个可以直接下载的地址用wget就可以下载
    lichao
    lichao
    Feb 13, 2014
    11
    WinSCP
    august
    august
    Feb 13, 2014
    12
    @sarices 你跟一樓發相同內容,你給折疊了
    sarices
    sarices
    Feb 13, 2014
    13
    @itfanr 是我发的,不知道为何变了@Keyes 发了
    rannnn
    rannnn
    Feb 13, 2014❤️1
    14
    有GUI的FileZilla干嘛要用命令行呢
    sarices
    sarices
    Feb 13, 2014
    15
    @august 没有提示折叠啊,之前好像有提示的
    itfanr
    itfanr
    OP
    Feb 13, 2014
    16
    @sarices 当然假设是不能公开的代码
    viator42
    viator42
    Feb 13, 2014❤️1
    17
    我一般filezilla连sftp,打个tar包再上传.
    itfanr
    itfanr
    OP
    Feb 13, 2014
    18
    @viator42 貌似这个方案比较好~谢谢
    sarices
    sarices
    Feb 13, 2014
    19
    @itfanr 一般用sftp就够了,如果你本机是Linux,可以用rsync scp
    zoowii
    zoowii
    Feb 13, 2014
    20
    scp
    itfanr
    itfanr
    OP
    Feb 13, 2014
    21
    @sarices 嗯嗯 灰常感谢!!!
    yuelang85
    yuelang85
    Feb 13, 2014
    22
    rsync
    wwek
    wwek
    Feb 13, 2014
    23
    svn
    git
    sftp
    Livid
    Livid
    MOD
    PRO
    Feb 13, 2014
    24
    @sarices 内容完全一样的回复,会被折叠。

    1 楼的提交时间比你的 2 楼稍微快了一点点,因为文字内容完全一样,所以 2 楼不显示。
    tonghuashuai
    tonghuashuai
    Feb 13, 2014
    25
    ftp
    Keyes
    Keyes
    Feb 13, 2014
    26
    @itfanr WinSCP+SFTP一般够了,不过我现在是在用sublime text+sftp plugin,开发来说后者好用得多。生产环境部署,可以通过很多种方式来进行,比如搭建一个GIT,在dev分支开发,定期merge到稳定分支,生产环境定期从稳定分支拉取新版本部署,反正都比较灵活,看你的习惯了
    yinheli
    yinheli
    Feb 13, 2014❤️1
    27
    你是 windows 用户,推荐3种途径:

    1. 如果安装了 git, 应该可以使用 scp 命令, 服务端添加 ssh key 后, 可以很方便的使用 scp 上传文件
    2. 如果安装了xhell(服务端需要安装 lrzsz [yum install lrzsz])可以直接通过 xhell 窗口拖拽你要上传的文件(相当于在shell里输入了 rz 命令) 这种方式每次只能上传一个文件
    3. 安装类似 `SftpNetDrive` 之类的工具, 它可以把 linux 服务器的某个路径映射成你的本地磁盘,用起来就像你的本地 C盘,D盘一样, 用起来也很方便的 (你和远程主机的网速不好的情况下, 就不要使用这种方式了, 经常连接掉了会比较痛苦)
    yinheli
    yinheli
    Feb 13, 2014
    28
    @yinheli 打错字了, 好像不能修改, 应该是 xshell
    lwrless
    lwrless
    Feb 13, 2014
    29
    @yinheli xshell好像可以跟xftp联动,如果装了xftp的话,点xshell界面里的xftp图标会打开一个连接到服务器的xftp,不管服务器开没开ftp的服务...(而且比如我的xshell正在/home/wwwroot目录下,然后我点开xftp,也会在这个目录)
    rebornix
    rebornix
    Feb 13, 2014
    30
    rsync
    Owenjia
    Owenjia
    Feb 13, 2014 via Android
    31
    除 sftp 外还可以用 netcat
    46fo
    46fo
    Feb 13, 2014
    32
    大量代码 为什么没人建议压缩成压缩包 然后再上传 文本压缩率很高的
    itfanr
    itfanr
    OP
    Feb 13, 2014
    33
    @Keyes
    @yinheli
    @Owenjia 一一感谢~~~
    itfanr
    itfanr
    OP
    Feb 13, 2014
    34
    @xdeng 压缩包也可以啊 我问的就是上传方式
    firstway
    firstway
    Feb 13, 2014
    35
    lz没说清楚使用场景,是一次性传很多文件?还是频繁修改,每次文件不大?
    前者一般rsync scp就ok了,反正次数不多,linux下rsync scp很方便,windows对应客户端找找。
    后者还是建议git svn等,作为开发人员,没版本管理说不过去。

    @xdeng rsync本身就有压缩选项。
    thinkxen
    thinkxen
    Feb 13, 2014 via Android
    36
    http://sshtool.net/down/
    头两个工具你会喜欢的
    fire5
    fire5
    Feb 13, 2014
    37
    svn
    SharkIng
    SharkIng
    Feb 13, 2014
    38
    @yinheli Mac或Linux下有没有类似工具或者类似办法的?? SFTPNetDrive
    itfanr
    itfanr
    OP
    Feb 13, 2014
    39
    @firstway 我想要的是前者吧 谢谢你
    itfanr
    itfanr
    OP
    Feb 13, 2014
    40
    @thinkxen 果然不错啊 谢谢
    mindcat
    mindcat
    Feb 13, 2014
    41
    tar cJf - $DIRECTORY | ssh $HOST "tar xJvf -"
    jatsz
    jatsz
    Feb 13, 2014
    42
    可以选择的:
    1,cygwin, scp, 先tar,gzip一下,然后到服务器端再解压缩。
    2,dropbox,在Windows和Linux都用同一个账号。dropbox会帮你自动同步,你直接在Windows下copy到dropbox文件夹下即可。
    wulin
    wulin
    Feb 13, 2014
    43
    xshell的xftp,拖动就可以了,
    或者打zip包后rz /sz
    webjin
    webjin
    Feb 13, 2014
    44
    xshell下直接按快捷键ctrl+alt+F就可以打开sftp传输界面,然后直接把文件拖进去~
    fcicada
    fcicada
    Feb 13, 2014
    45
    git很方便,也适合管理
    jacky007wang
    jacky007wang
    Feb 13, 2014
    46
    fabric
    zhouquanbest
    zhouquanbest
    Feb 13, 2014
    47
    我一直使用rsync 繁多的选项应该能满足你的需求
    undozen
    undozen
    Feb 13, 2014 via iPad
    48
    我会在远程主机上建 repo 和 prod 两个文件夹
    repo 里面 git init --bare
    然后z在 prod 里面 clone 跑起来
    lm902
    lm902
    Feb 13, 2014
    49
    我是在本机配置好IIS8.5然后在服务器上wget下载最后tar -xvf解压
    ibcker
    ibcker
    Feb 14, 2014
    50
    zip&sftp&uzip
    git
    scp
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2420 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 99ms · UTC 11:03 · PVG 19:03 · LAX 03:03 · JFK 06:03
    ♥ Do have faith in what you're doing.