SSH/Transfer Files - Securely

Another important function of SSH is allowing secure file transfer using SCP and SFTP.

 

Secure Copy (scp)

Just as all modern Unix-like systems have an SSH client, they also have SCP and SFTP clients. To copy a file from your computer to another computer with ssh, go to a command-line and type:

 

scp <file> <username>@<IP address or hostname>:<Destination>

For example, to copy your TPS Reports to Joe's Desktop:

 

scp "TPS Reports.odw" joe@laptop:Desktop/

This will copy TPS Reports.odw to /home/joe/Desktop, because SCP uses your home folder as the destination unless the destination folder begins with a '/'.

To copy the pictures from your holiday to your website, you could do:

 

scp -r /media/disk/summer_pics/ mike@192.168.1.1:"/var/www/Summer 2008/"

The -r (recursive) option means to copy the whole folder and any sub-folders. You can also copy files the other way:

 

scp -r catbert@192.168.1.103:/home/catbert/evil_plans/ .

The '.' means to copy the file to the current directory. Alternatively, you could use secret_plans instead of '.', and the folder would be renamed.

 

Secure FTP (sftp)

Finally, if you want to look around the remote machine and copy files interactively, you can use SFTP:

 

sftp linus@kernel.org

This will start an SFTP session that you can use to interactively move files between computers.

  • 0 Uživatelům pomohlo
Byla tato odpověď nápomocná?

Související články

How To: Back Up MySQL Databases From The Command Line

While automated backups are important, sometimes you just want to take a quick and dirty snapshot...

How To Install MariaDB on CentOS 6

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and...

How to Display (List) All Jobs in Cron / Crontab

View Root’s Cron Jobs crontab -l  View a User’s Cron Jobs crontab -u username -l Example with...

How To: Automate Server Scripts With Cron

Servers can automatically perform tasks that you would otherwise have to perform yourself, such...

How to find sending spam emails and enable mail header in php.ini

- In Linux servers if there are a lot of emails in the queue "over 100" emails. you can check if...