• Home
  • About
    • Guitarliu photo

      Guitarliu

      A programmer who loves guitar, Typing Csharp and Python.

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Ubuntu-Windows通过SSH互传文件

21 Mar 2021

Reading time ~1 minute

Ubuntu端安装并启动ssh服务:

sudo apt-get install openssh-server
sudo service ssh start

Windows10端安装ssh服务:

Windows10端系统自带openssh服务,所以只需在命令行调用即可。如下图:

Windows10通过ssh连接Ubuntu服务器

ssh username@hostname -p port
  • username为Linux端用户名

  • hostname为Linux端IP地址,查找Linux端IP地址可用ifconfig;如果输入ifconfig报错,说明Linux端未安装ifconfig,需要通过sudo apt-get install ifconfig 安装 ifconfig
  • port为ssh端口,默认为22

上传Windows10文件至Linux端

  • 上传Windows10某一路径下某一文件至Linux端某一文件夹处。打开Windows10终端,输入以下命令:

    scp [windows-filespath/filename] username@hostname:path/destination_filepath
    
  • 上述windows-filespath/filename为Windows10的文件名,username为Linux端用户名

  • 如果需要上传文件夹至Linux端,只需在scp后面加一个 -r 即可,即:

    scp -r [windows-filespath/filename] username@hostname:destination_dir
    

下载Linux至Windows10

  • 下载Linux某一文件夹路径下某一文件至Windows10某一路径下(如桌面)

    • 打开Windows10终端,输入以下命令:
      scp username@hostname:path/sourcefilename [windows-destination-path]
    

    上述username为Linux的用户名,[windows-destination-path]为Windows10端文件夹

    如果需要下载文件夹至Windows10,只需在scp后面加一个 -r 即可,即:

      scp -r username@hostname:path/source_dirname [windows-destination-path]
    


Ubuntu and WindowsSSHFile Transport Share Tweet +1