Cool way to get large files onto a remote server with an SSH connection.

If you are using a remote server with SSH and you wish to get a large file off the Internet to the remote server easily, you may use the wget command to download it directly to the server instead of having to download it at home and then upload it again. That is silly. Use the wget command like this to fetch the file.

ubuntu ~ $ wget

This makes much more sense than the aforementioned method of downloading and then uploading files. Remote Windows servers with web upload forms I am looking at you. Just right-click on the link and choose to “Copy Link Location”, then paste it into the terminal as shown above and download the file directly to the remote server. Nice huh? This makes things much easier and faster. I have tried to upload large files to a Windows server online using the web upload forms, but it would just give and error once it got to 90% uploaded. This way works much better. An SSH connection is preferable for any kind of remote administration. Linux is a multi-user operating system and it is meant to be used over a network. The Internet is perfect for this, connecting over this world-wide network to a machine in another country seems like magic, but it does work.

There is a nice man page for SSH here, this explains everything that you need to know to get your head around using this to securely connect to remote machines.

Some useful Linux networking commands.

This command will return only the IP address of the host. Very useful in a script.

ubuntu ~ $ hostname -i

Querying for all local IP addresses on the host.

ubuntu ~ $ hostname -I

This simple script will ping Google and will check the return value of the ping command to see if the Internet is up or not.

ping -c 1
if [ "$?" == "0" ]; then;
echo "Hi."
echo "The Internet is down."

This is yet another way to get IP address information from the host. This lists active IP addresses on the host network adapters.

ubuntu ~ $ ip a | grep inet
    inet scope host lo
    inet6 ::1/128 scope host
    inet brd scope global eth0
    inet6 fe80::4d6:3aff:fea8:8213/64 scope link
    inet peer scope global tun1194

The nslookup command is used to retrieve DNS information about a certain host. This returns the DNS servers that service that website/host.

ubuntu ~ $ nslookup
Non-authoritative answer:

Use netstat to list all Internet connections from your machine. Here I am listing all of the listening connections on my cloud instance.

ubuntu ~ $ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:mysql         *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 *:https                 *:*                     LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
udp        0      0 *:bootpc                *:*
udp        0      0 *:10995                 *:*
udp        0      0 *:2302                  *:*
udp        0      0 *:2303                  *:*
udp        0      0 *:2304                  *:*
udp        0      0 *:2305                  *:*
udp6       0      0 [::]:13242              [::]:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     SEQPACKET  LISTENING     1171791  /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     73100    @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     8809     /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     9104     /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     640253   /var/run/mysqld/mysqld.sock

No comments have been made. Use this form to start the conversation :)

Leave a Reply