LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Questions about ssh, ftp, sftp, scp (https://www.linuxquestions.org/questions/linux-newbie-8/questions-about-ssh-ftp-sftp-scp-904383/)

Blackened Justice 09-22-2011 05:07 AM

Questions about ssh, ftp, sftp, scp
 
Hey everyone,

At my University we have a Linux Cluster that I can access from home using ssh. My question is, how can I transfer files from the Cluster to my pc and vice-versa. The instructions on their site point to using scp, but someone else mentioned ftp or sftp. How do I use any of those?



Cheers

colucix 09-22-2011 06:50 AM

You can either use scp and sftp, not ftp. The scp command is similar to cp, but you have to provide the username and the hostname of the remote machine in the source or destination path. Suppose you want to copy a file from the remote server to your local machine at home:
Code:

scp user@hostname:/path/to/remote/file .
this one copies /path/to/remote/file from the server hostname to the current working directory on your machine. Most likely you have to put the IP address of the remote server in place of the hostname, unless you associate the IP with the hostname in the file /etc/hosts on your local machine.

Some useful options of the scp command are -r to recursively copy entire directories and -p to preserve the original timestamp and permission of the remote file. Please, see man scp for details.

The sftp command is similar to ftp. You open a sftp session, then you use the sftp commands (put, get and so on). quit to close the session. Again, please see man sftp for details. Feel free to ask if you some specific problem.

Blackened Justice 09-22-2011 12:22 PM

All of the above information assumes that I'm logged in my current machine and not in the remote machine, right? Is there a way to transfer if I'm logged into the remote machine? I'm going to read up on sftp, it may solve my doubts.

colucix 09-22-2011 12:31 PM

You can connect to a machine if it has a running ssh server. Most likely your machine at home has the port 22 (ssh port) closed and hasn't got a running sshd. If you trust the network you can try to open port 22, but I'd suggest to adopt some security measure to prevent undesired intrusions (disable password login, enable public-private key authentication, restrict the access to known IP addresses and so on). The question is: is it worth the risk and the additional work? Can't you simply transfer files when you are physically at home and not vice-versa?

Blackened Justice 09-23-2011 03:56 AM

Ok, thank you for the tips ;)

Just another thing, is there any way to mount a directory that is on a remote host locally?

colucix 09-23-2011 04:14 AM

Yes, take a look at sshfs. I tried it and it worked flawlessly.

schneidz 09-23-2011 01:32 PM

Quote:

Originally Posted by Blackened Justice (Post 4478997)
Hey everyone,

At my University we have a Linux Cluster that I can access from home using ssh. My question is, how can I transfer files from the Cluster to my pc and vice-versa. The instructions on their site point to using scp, but someone else mentioned ftp or sftp. How do I use any of those?



Cheers

dont use ftp because it is old, deprecated and insecure.

scp is usually used for machines to transfer stuff automatedly (especially when using ssh-keys)
sftp also runs over ssh but prompts the user for username, password, local-file, remote-file, ...

consider installing sshfs.

Blackened Justice 09-23-2011 02:33 PM

Ok, thank you very much, sshfs solved my problem easily ;)


All times are GMT -5. The time now is 10:33 AM.