D
D
Davidaa_WoW2022-03-09 22:26:58
linux
Davidaa_WoW, 2022-03-09 22:26:58

How to download a file from a site using the scp and sftp command?

According to the assignment, at first there was interaction using ssh and sftp, in fact, with itself, connecting to localhost, with which there were no problems, just the scp and get commands, respectively.
However, the next task is to download a file from some remote resource. The following is given as an example: ftp://ftp.hp.com:21/pub/softpaq/sp40001/sp40001.cva Failed
to solve "on the forehead" - scp ftp://ftp.hp.com:21/pub/softpaq /sp40001/sp40001.cva localhost gives an error, it also failed to connect via ssh to ftp.hp.com. So what to do in this situation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Drno, 2022-03-09
@Drno

scp to connect via ssh
to download via ftp It is logical to use wget
wget ftp://ftp.hp.com/pub/softpaq/sp40001/sp40001.cva

R
rPman, 2022-03-09
@rPman

curl is a high-level utility that supports almost all protocols

DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP.

therefore, your task could be solved only by it, just specify the path in the appropriate format scp://user:[email protected] ... sftp://... and so on. of course, passwordless key authentication also works
error messages should describe in detail the reason why something is not working for you, and the -v key will add details
If the specified links to ftp hp do not work from Russia, so use, for example, a proxy, in curl, it is enabled with the key --proxy socks5://ip:port if the socks5 version is used (the local socks5 proxy is raised by ssh connecting to a remote server by simply connecting there with the key ssh [email protected] -D1080 where port is 1080, and the socks server will be on localhost ).
ps scp is a standard mechanism for working with files over an ssh connection, i.e. it seems that it will work under any exotic conditions (sometimes even a user is specifically started only with scp access)
sftp is an ftp connection, having previously connected via ssh to the server
, and for backfilling, you can copy files simply with the ssh utility using stream redirection
tar -c /source/files | ssh [email protected] "cd /path/to/;tar -x --"

here the tar archiver packs local files, and outputs the resulting archive to stdout, which is transmitted via ssh connection to a remote tar that unpacks everything already on a remote server
, this approach is simple, does not require anything to be configured and installed on servers (it will probably work on 20-year-old pieces of iron) but it doesn't handle errors properly, i.e. if something goes wrong, everything will be interrupted

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question