Transfer files ssh windows linux

Copying a local file from Windows to a remote server using scp [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I try to transfer a folder of files from my local computer to a server via ssh and scp . After getting sudo privileges, I’m using the command as follows:

scp -r C:/desktop/myfolder/deployments/ user@host:/path/to/whereyouwant/thefile 

None of the non-GUI solutions work for me. I get the error, fork: No such file or directory. I can ssh the destination and I can dir to the source.

7 Answers 7

If your drive letter is C, you should be able to use

scp -r \desktop\myfolder\deployments\ user@host:/path/to/whereyouwant/thefile

without drive letter and backslashes instead of forward slashes.

You are using putty, so you can use pscp. It is better adapted to Windows.

scp -r root@31.222.168.64:/var/www/vhosts/mywork \test — I added this code this is create a test folder in my server no in my local computer scp -r root@31.222.168.64:/var/www/vhosts/mywork D:\test —gives error «ssh: Could not resolve hostname D: Name or service not known lost connection»

@pTi which scp are you using? If you are using Cygwin’s scp , you can use the path as /cygdrive/d/test . To omit using /cygdrive you can run mount —change-cygdrive-prefix / so that the path would be /d/test instead.

Not sure if it’s specific to tunneling or to the version of scp in Windows 10, but I had to use the syntax (after lots of trials and errors): scp -P -r ./localdir user@host:»D:\remotedir»

Drive letters can be used in the target like

scp some_file user@host:/c/temp 

where c is the drive letter. It’s treated like a directory.

Maybe this works on the source, too.

Thanks for this simple and working answer, not trying to make me use another software or whatever ! I was searching the web to find just that, nobody answers the question directly.

In my case, user@host:/ is the root for my C:\ directory. So if I write user@host:/temp/ , it is equivalent to C:\temp\ . I only have access to my C Drive, not others.

@imans77, that may work, but if your drive letter is e: it won’t 😉 That was the case for me and how I discovered this.

On windows you can use a graphic interface of scp using winSCP. A nice free software that implements SFTP protocol.

I see this post is very old, but in my search for an answer to this very question, I was unable to unearth a solution from the vast internet super highway. I, therefore, hope I can contribute and help someone as they too find themselves stumbling for an answer. This simple, natural question does not seem to be documented anywhere.

Читайте также:  Linux resolv search domain

On Windows 10 Pro connecting to Windows 10 Pro, both running OpenSSH (Windows version 7.7p1, LibreSSL 2.6.5), I was able to find a solution by trial and error. Though surprisingly simple, it took a while. I found the required syntax to be

BY EXAMPLE INSTEAD OF MORE OBSCURE AND INCOMPLETE TEMPLATES:

Transferring securely from a remote system to your local system:

scp user@remotehost:\D\mySrcCode\ProjectFooBar\somefile.cpp C:\myRepo\ProjectFooBar 

or going the other way around:

scp C:\myRepo\ProjectFooBar\somefile.cpp user@remotehost:\D\mySrcCode\ProjectFooBar 

I also found that if spaces are in the path, the quotations should begin following the remote host name:

scp user@remotehost:"\D\My Long Folder Name\somefile.cpp" C:\myRepo\SimplerNamerBro 

Also, for your particular case, I echo what Cornel says:

On Windows, use backslash, at least at conventional command console.

Kind Regards. RocketCityElectromagnetics

Источник

How to transfer files over SSH with SSHFS in Linux & Windows

There are various tools available to copy files and directories between Linux server. In this article we will use SSHFS to transfer files over SSH from local to remote and remote to local server.

You can also use below tools to copy files between Linux servers:

Overview on SSHFS

  • SSHFS (Secure SHell FileSystem) is a file system for Linux (and other operating systems with a FUSE implementation, such as Mac OS X or FreeBSD) capable of operating on files on a remote computer using just a secure shell login on the remote computer.
  • The sshfs command is a client tool for using SSHFS to mount a remote file system from another server locally on your machine.
  • SSHFS allows you to mount a remote directory from remote server on your local machine using a mount point, and have it treated just like any other directory.

Advantage of using SSHFS

  • Compared to other shared filesystem such as NFS and Samba we do not need any server or client side configuration
  • SSHFS is a simple client tool which does not requires any additional configuration
  • You can also use SSHFS to transfer files over SSH between Linux and Windows Server
  • The files are transferred in completely encrypted channel so it is very secure

Drawbacks of using SSHFS

  • You mount the remote directory on local server similar as NFS server but with transfer over SSH using SSHFS both encryption and decryption is involved which can cause performance impacts
  • You should also save your data on the mount point as if there is a network connection problem then you may loose your data

Transfer File over SSH between two Linux servers

Install SSHFS on Linux

SSHFS is an opensource project and is not available in most default repositories of distributions

To install SSHFS on RHEL/CentOS 7, we must first install EPEL repository

# yum -y install epel-release

Next install sshfs on your client node

[root@server1 ~]# yum -y install sshfs

To install sshfs on Ubuntu and Debian

Mount Remote File System

To transfer files over SSH using SSHFS, we must execute SSHFS using below syntax:

sshfs [user@]host:[dir] mountpoint [options]

Check sshfs -h to get the complete list of supported options

Читайте также:  Установить время дату linux

In this example I have installed SSHFS on server1 and we will mount

Remote directory ( /shared ) from server2

[root@server2 ~]# ls -l /shared/ total 0 -rw-r--r-- 1 root root 0 May 17 19:21 file1 -rw-r--r-- 1 root root 0 May 17 19:21 file2 -rw-r--r-- 1 root root 0 May 17 19:21 file3

to my local Linux node on server1 at ( /mount_point )

[root@server1 ~]# ls -l /mount_point/ total 0

So we must execute sshfs on server1 , we are using root user to transfer files over SSH. You can use any normal user, but make sure this user has enough permission to access the remote directory on server2

[root@server1 ~]# sshfs root@192.168.43.10:/shared /mount_point root@192.168.43.10's password:

There was no error reported so the mount was successful. Verify the mount point on server1

[root@server1 ~]# mount | grep shared root@192.168.43.10:/shared on /mount_point type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0)

You can now access the content of remote directory ( /shared ) from server2 on /mount_point directory on local Linux node at server1

[root@server1 ~]# ls -l /mount_point/ total 0 -rw-r--r--. 1 root root 0 May 17 19:21 file1 -rw-r--r--. 1 root root 0 May 17 19:21 file2 -rw-r--r--. 1 root root 0 May 17 19:21 file3

Now we can add and modify content under /mount_point at server1 and the changes will be reflected runtime on server2 at /shared

How to transfer files over SSH with SSHFS in Linux & Windows

To permanently mount this remote directory use /etc/fstab using below syntax:

user@host:/remote/path /local/mount_point fuse.sshfs defaults 0 0

In this example we will add below content in our /etc/fstab

root@192.168.43.10:/shared /mount_point fuse.sshfs defaults 0 0

Un-mount Remote File System

Once you have transferred your files, you can also un-mount the remote file system using umount . Execute umount on server1 :

[root@server1 ~]# umount /mount_point/

Verify and make sure there are no mount paths using /shared directory from remote server i.e. server2

[root@server1 ~]# mount | grep shared

Transfer File over SSH between Windows and Linux servers

  • You can also use SSHFS to transfer files over SSH between Windows and Linux server.
  • This can also be achieved using Samba but let us concentrate on SSHFS for the sake of this article

Install SSHFS on Windows

  • To transfer files over SSH between Windows and Linux, you must install SSHFS on the WIndows server.
  • You can get the files required to installed from the official Github page
  • Download WinFsp and follow the onscreen instructions to install WinFsp on your Windows server
    Download SSHFS-Win and follow the onscreen instructions to install SSHFS-Win on your Windows server
  • At the time of writing this article I have installed winfsp-1.6.20027.msi and sshfs-win-3.5.20024-x64.msi

Mount Remote File System

Once you have installed WinFsp and SSHFS-Win on your windows server, next we must map the network location from remote server to a local mount point

I am using WIndows 10 so I will share the instructions based on my environment.

In Windows Explorer select This PC ⇒ Map Network Drive

How to transfer files over SSH with SSHFS in Linux & Windows

Provide the path of your remote server and remote directory using the below syntax

Here we cannot directly give our mount point as /shared from our remote Linux server. We must use (/) to navigate around the Linux server. In this example we will connect to the home folder of our root user using

How to transfer files over SSH with SSHFS in Linux & Windows

Provide the login credentials for root user from the remote server i.e. server2

Читайте также:  Linux owner group permissions

How to transfer files over SSH with SSHFS in Linux & Windows

If all is good, you will be connected to your remote Linux server using Windows server. You can verify the path in the Navigation Pane. By default we are connected to home folder of root user

How to transfer files over SSH with SSHFS in Linux & Windows

How to connect to different folder using SSHFS in Windows?

In Windows SSHFS we are by default connected to user’s home directory so we must provide the absolute path using navigation symbols i.e. to go to /shared directory our path to transfer files over SSH on Windows would be //sshfs/root@192.168.43.10/../shared

If you NOTICE, I have first changed my current directory using ../ followed by the path of /shared directory. I hope you understand the point.

How to transfer files over SSH with SSHFS in Linux & Windows

Now we are connected to /shared directory where we had created three dummy files on server2

How to transfer files over SSH with SSHFS in Linux & Windows

For list of Advanced Usage with Windows SSHFS, check the official Github page for instructions

Disconnect Remote File System

Once you are done, to disconnect the network drive, in Windows Explorer select This PC . Look out for your mapped drive and Right Click on the drive to get a list of options. Select Disconnect to remove the mapped drive from your Windows server.

How to transfer files over SSH with SSHFS in Linux & Windows

Conclusion

Lastly I hope the steps from the article to configure NIC teaming on Linux was helpful. In this tutorial we learned about SSHFS and how we can use SSHFS to transfer files over SSH between two Linux servers or between Linux and Windows server. So, let me know your suggestions and feedback using the comment section.

References

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

Can I transfer files using SSH?

I am using PuTTY on Windows 7 to SSH to my school computer lab. Can I transfer files from my Windows machine to my user on the school machines using SSH?

@dr01 true but it’s got a lot of upvotes so it’s probably worth leaving for posterity, and moving on.

7 Answers 7

Use the PSCP tool from the putty download page:

PSCP is the putty version of scp which is a cp (copy) over ssh command.

PSCP needs to be installed on your windows computer (just downloaded, really, there is no install process. In the Packaged Files section, pscp.exe is already included). Nothing needs to be installed on the school’s servers. PSCP and scp both use ssh to connect.

To answer the usage question from the comments:

To upload from your computer to a remote server:

c:\pscp c:\some\path\to\a\file.txt user@remote:\home\user\some\path 

This will upload the file file.txt to the specified directory on the server. If the final part of the destination path is NOT a directory, it will be the new file name. You could also do this to upload the file with a different name:

c:\pscp c:\some\path\to\a\file.txt user@remote:\home\user\some\path\newname.txt 

To download a file from a remote server to your computer:

c:\pscp user@remote:\home\user\some\file.txt c:\some\path\to\a\ 
c:\pscp user@remote:\home\user\some\file.txt c:\some\path\to\a\newfile.txt 
c:\pscp user@remote:\home\user\some\file.txt . 

With a lone dot at the end there. This will download the specified file to the current directory.

Источник

Оцените статью
Adblock
detector