- How to save a file from Linux on to your desktop?
- 4 Answers 4
- How to SCP from Linux server to Windows client
- 9 Answers 9
- Get an admin command prompt
- Check available versions
- Install client
- Install server
- Start server and enable at boot
- Find your Windows IP address
- On your remote (Linux) machine, find your IP address.
- Create a public SSH key
- Copy public key from local (Windows) to remote (Linux) machine so you don’t have to type in a password all the time.
- Note that ssh-copy-id is not currently available on Windows.
- Do the same on your Linux machine (Note, ssh-copy-id does not work)
- Create a password on Windows if you don’t already have one
- Now you should be able to SSH or SCP from your Linux machine
- How to Download Files from the Linux Command Line
- How to Download a File From a Server to Your Desktop Using SSH
- Step 1: Gather the Necessary Information
- Step 2: Create the SCP Command
- Step 3: Running the Command
How to save a file from Linux on to your desktop?
I have began using Putty.exe on a university computer that is also connected to the university server. I have a pdb file saved in my Linux directory. Is it possible to save this pdb file onto the desktop of the current computer I am using so I can e-mail it to myself?
I would like to learn how to save Linux files onto my desktop (when using the university server). I have researched on my own and have found out that when you are using your own computer or personal laptop at home, I could potentially save a file (using command cp to copy it actually) to my desktop using a direct path however, I am having trouble completing this on a university server.
4 Answers 4
PuTTY should come with scp client pscp . You can use it from command line:
Where user and host refer to the server you are connecting to. Source is the path to the file on server, and target is path to where you want to save the file on your client.
If you are using Linux client, your system possibly already has scp installed. scp can be used with same syntax.
Using SCP with pscp is a good option, as given by sebasth. SFTP with psftp is another option. You probably cannot install software on the university workstation, but you can probably download and execute Putty’s psftp , which is «command-line secure file copy.»
When you first start this program, it might look as follows.
Do this using the same credentials that you use for SSH. For example,
(Or, use its IP address if you don’t have a hostname.)
Type help to view available commands. Of note, pay attention to lcd . The meaning is «local change directory.» This changes the working directory of the program. When you download a file, the file will be downloaded into the working directory. One might use lpwd to print the local working directory. Also note that local commands can be executed with ! . To get a local directory listing, type !dir . As an exercise, try these to get a feel for what is happening.
Now, get a directory listing on the remote side.
Use get to download a single file. Use mget to download multiple files at once, for example, mget a* to download all files beginning with the lower-case letter, a. (The uploads use put and mput .)
To end the SFTP session, type bye .
On a personal computer where you can install software, try any SFTP client. FileZilla. WinSCP. WinSSHFS. Or search for one you like best.
Источник
How to SCP from Linux server to Windows client
I’m SSHing into a Linux machine using PuTTY and trying to copy a file down somewhere (anywhere) to my local machine. I figure SCP is the best candidate for the job but don’t really care, so long as the solution works!
I cd to the directory containing the file I want ( app.war ) and type the following:
I’ve tried both to no avail:
It got me thinking that perhaps SCP is a client/server tool and requires a client on my Windows machine, which isn’t there.
Am I just using the wrong syntax? Or am I way off-base? If so, what options do I have? Thanks in advance!
9 Answers 9
in order for you to copy files back to your Windows you need SSH daemon/service to be running on your Windows, it’s much easier to use this tool instead, it has an ability to import sessions from Putty, very plain forward client you’ll love it!
You are correct. SSHD is the SSH server services that runs on the host. It accepts connections from SSH clients (like PuTTy), SCP clients, and SFTP clients.
You can download pscp from the same website where PuTTY is hosted.
From the windows machine, you would execute a command similar to
pscp.exe someuser@somehost.com:/path/to/app.war c:\tmp
Get an admin command prompt
Check available versions
Install client
Install server
Start server and enable at boot
Find your Windows IP address
On your remote (Linux) machine, find your IP address.
Create a public SSH key
Copy public key from local (Windows) to remote (Linux) machine so you don’t have to type in a password all the time.
Note that ssh-copy-id is not currently available on Windows.
Do the same on your Linux machine (Note, ssh-copy-id does not work)
The method above did not work for me, so I ended up manually SCPing the public key over and pasting it into the C:/Users/YOU/.ssh/authorized_keys file.
That still did not work, so I had to modify the sshd_config file.
Open Notepad as Administrator
Add the following lines:
Create a password on Windows if you don’t already have one
— Note, you can still disable the Windows login screen by a) Setting the ‘Require sign-in’ option to never and b) Using the ‘netplwiz’ command and unticking the ‘Users must enter password. ‘ checkbox.
Now you should be able to SSH or SCP from your Linux machine
You can do this by using the Linux Ubuntu subsystem for Windows (you need to enable this as a Windows feature). Then you can use a Linux terminal client that runs on Windows by getting it from the Microsoft Store (e.g. Ubuntu 16.04 LTS). Then, if you have ssh security set up to remote into your Linux machine, you can scp from your local Windows Ubuntu terminal (when logged in as the username that you set for your Linux instance) something like this:
/ . enter RSA passphrase
The remote file will be copied into your local Ubuntu filesystem used by Windows e.g.
To SCP a file to a Windows machine, you need an SSH/SCP server on the Windows.
There’s no SSH/SCP support in Windows by default. You can install Microsoft build of OpenSSH for Windows (Releases and Downloads). It’s available as optional feature on Windows 10 version 1803 and newer. It can also be manually installed on older versions of Windows.
Though as you SSH into the Linux server from the Windows machine, you actually can download a file from the Linux server to the Windows server, instead of trying to upload the file from the Linux server to Windows server.
In you have an SSH access from Windows to Linux, you have an SCP access too (or even better an SFTP access).
Use any SCP/SFTP client available.
Another alternative is PuTTY toolset, which includes the pscp command-line tool with a syntax similar to the OpenSSH scp command. Also the latest versions of Windows 10 comes with OpenSSH scp built-in and it can be installed on older versions too.
Источник
How to Download Files from the Linux Command Line
This guide will teach you step by step how to download files from the command line in Linux, Windows or macOS using open source (free) software – wget. Wget is a very cool command-line downloader for Linux and UNIX environments that has also been ported to Windows and macOS. Don’t be fooled by the fact that it is a command line tool. It is very powerful and versatile and can match some of the best graphical downloaders around today. It has features such as resuming of downloads, bandwidth control, it can handle authentication, and much more. I’ll get you started with the basics of using wget and then I’ll show you how you can automate a complete backup of your website using wget and cron.
Let’s get started by installing wget. Most Linux distributions come with wget pre-installed. If you manage to land yourself a Linux machine without a copy of wget try the following. On a Red Hat Linux based system such a Fedora you can use:
# yum install wget
or if you use a Debian based system like Ubuntu:
# sudo apt-get install wget
One of the above should do the trick for you. Otherwise, check with your Linux distribution’s manual to see how to get and install packages. Users on Windows can access wget via this website, and for Mac users we have a full guide on how to install wget in macOS.
The most basic operation a download manager needs to perform is to download a file from a URL. Here’s how you would use wget to download a file:
# wget https://www.simplehelp.net/images/file.zip
Yes, it’s that simple. Now let’s do something more fun. Let’s download an entire website. Here’s a taste of the power of wget. If you want to download a website you can specify the depth that wget must fetch files from. Say you want to download the first level links of Yahoo!’s home page. Here’s how would do that:
# wget -r -l 1 https://www.yahoo.com/
Here’s what each options does. The -r activates the recursive retrieval of files. The -l stands for level, and the number 1 next to it tells wget how many levels deep to go while fetching the files. Try increasing the number of levels to two and see how much longer wget takes.
Now if you want to download all the “jpeg” images from a website, a user familiar with the Linux command line might guess that a command like “wget http://www.sevenacross.com*.jpeg” would work. Well, unfortunately, it won’t. What you need to do is something like this:
# wget -r -l1 –no-parent -A.jpeg https://www.yahoo.com
Another very useful option in wget is the resumption of a download. Say you started downloading a large file and you lost your Internet connection before the download could complete. You can use the -c option to continue your download from where you left it.
# wget -c http://www.example_url.com/ubuntu-live.iso
Now let’s move on to setting up a daily backup of a website. The following command will create a mirror of a site in your local disk. For this purpose wget has a specific option, –mirror. Try the following command, replacing sevenacross.com with your website’s address.
# wget –mirror http://www.sevenacross.com/
When the command is done running you should have a local mirror of your website. This make for a pretty handy tool for backups. Let’s turn this command into a cool shell script and schedule it to run at midnight every night. Open your favorite text editor and type the following. Remember to adapt the path of the backup and the website URL to your requirements.
BACKUP_PATH=`/home/backup/` # replace path with your backup directory
WEBSITE_URL=`http://www.sevenacross.net` # replace url with the address of the website you want to backup
# Create and move to backup directory
cd $BACKUP_PARENT_DIR/$YEAR/$MONTH
mkdir $DAY
cd $DAY
Now save this file as something like website_backup.sh and grant it executable permissions:
# chmod +x website_backup.sh
Open your cron configuration with the crontab command and add the following line at the end:
0 0 * * * /path/to/website_backup.sh
You should have a copy of your website in /home/backup/YEAR/MONTH/DAY every day. For more help using cron and crontab, see this tutorial.
Now that you get the basics of downloading files from the command line you can get into the advanced stuff by reading up wget’s man page – just type man wget from the command line.
If this article helped you, I’d be grateful if you could share it on your preferred social network — it helps me a lot. If you’re feeling particularly generous, you could buy me a coffee and I’d be super grateful 🙂
Источник
How to Download a File From a Server to Your Desktop Using SSH
An SSH session is like a portal into another machine. If you’re used to working with Windows, you’ll know how easy it is to transfer files from one location to another. Just drag and drop! No text commands, no authentication, none of that.
However, sometimes you will need to download a file from SSH to your local desktop, such as if you are using one of our Linux VPS servers. And there’s no simple command from within the SSH terminal itself to do this. The two environments are too far apart. However, we have a dedicated tool called “SCP” which stands for “Secure Copy” that’s made for precisely these kinds of situations.
Here’s how it works. First, we have a file on the remote server called filetodownload.txt , as shown here:
We’re going to transfer this file from Linux to our Windows desktop.
Table of Contents
Step 1: Gather the Necessary Information
To transfer a file from a remote server via SSH using SCP, we need the following pieces of information:
- Login credentials – username, server name or IP address, and password
- The port number for SSH connections
- The path to the file on the remote server
- The path to the download location
You should already have the login credentials when you connect to the server using PuTTY, or some other tool, so we won’t go into it here.
As for the port number, you’ll need to know which SSH server port your VPS listens to. It’ll either be 22 (the default port), or it’ll be given to you when you order your VPS from your hosting provider.
To get the full path to the file you want to transfer, enter the “pwd” command on the CLI of the remote server while the file is in your current directory. This will give you the folder name, like this:
Now just append the name of the file to the path you get and you’re done.
As for the path to the download location, that’s something you have to get on your own!
Step 2: Create the SCP Command
The SCP command looks like this:
Replace the sections in bold with the information you gathered in step 1. For example, the command used for this example is:
Step 3: Running the Command
Open up a command line in Windows. Windows 10 already has SCP installed by default. For this example, we’ll use the Windows PowerShell tool to run the commands. The color contrasts with the yellow, and syntax highlighting is a nice change from the drab command line.
Pasting the above command into the local command line editor gives us:
As you can see, you first need to confirm the connection using the RSA fingerprint of the remote server. Once you type “yes”, it’ll be permanently added to the “known_hosts” file.
The “known_hosts” file in Windows is located at:
Replace [UserName] with your own Windows username. It’s a file without an extension, like this:
An editor like Notepad++ is ideal for these kinds of files. Each RSA fingerprint is added on a new line. This allows you to clear them easily by deleting an entire line at once if you ever need to remove an entry.
Once you provide your password in the prompt, the file is downloaded immediately, as shown here:
And you’re done! Navigate to the location you specified in your SCP command and the file should be visible.
SCP is the most direct way to transfer files from remote servers to local systems. It makes use of the same SSH protocols, so the connection is encrypted all the way through, making it immune to man-in-the-middle attacks. Hopefully, this tutorial will help you use it in an efficient, and easy manner. If you use one of our Managed Linux VPS services, and you have an issue with SCP or need more information about it please don’t hesitate to contact our 24×7 Linux Server Support, which comes included with your hosting plan.
If this tutorial helped you move files from your remote server to your local machine, maybe consider sharing this knowledge with your friends by using our share shortcuts. You can also leave any additional tips or questions in our comment section below. Thank you.
Источник