Linux Run SCP command in background

Linux Run SCP command in background

Here is how you can keep the SCP command running even after closing the remote shell (e.g Putty)

Keep Process In Background

  1. Open ssh terminal to remote server.
  2. Type your scp command as normal
  3. Background the scp process by entering Ctrl+Z, then typing the command bg
  4. Disown the background process by typing disown
  5. Close the SSH session and you will see that it is still running

Verify Process Is Running

You can verify that it is running by checking the remote destination size. For example, using the command du -s <directory> to check a directory size, or ls -l <filename> to check a file size

Enjoyed the content ? Share it with your friends !

Linux Check SSH Login Attempts To Server

Linux Check SSH Login Attempts To Server

For CentOS or RHEL distros, the login attempts are stored at /var/log/secure

For Ubuntu, the login attempts are stored at /var/log/auth.log

Sample Commands (based on CentOS)

To read the file, simply run the command cat /var/log/secure

If your ssh allows for normal password authentication, you can check for failed login attempts by running the command cat /var/log/secure | grep "Failed password"

If your ssh allows for key-based login, you can check for failed login attempts by running the command cat /var/log/secure | grep -i Invalid

 

 

 

Enjoyed the content ? Share it with your friends !

PHP Linux How To Upload Files Into Block Storage

PHP Linux How To Upload Files Into Block Storage

Sometimes, you may need to use a huge amount of additional storage, and so some providers provide something called object storage, block storage or something along that line.

To store files or upload them into your object or block storage, there are 3 solutions.

1. Change Mount Point
To do this, you basically need to modify your /etc/fstab file.
Example Commands :

    1. modify /etc/fstab file : vi /etc/fstab
      You may have a line that looks like the one below

      /dev/sda1 /blockstorage ext4 defaults 00
      

      So you just have to modify the 2nd field which is the mount point/directory

    2. reload : mount -a
      note: you can use findmnt to check if your mount point has changed
      note: you may need to change the owner and group using chown

2. Use symlink command

ln -s  <somewhere in mount point> <somewhere in web directory>
ln -s /blockstorage /home/website.com/public_html/some_directory
Enjoyed the content ? Share it with your friends !

Lockdown port to specific ip address using iptables

Lockdown port to specific ip address using iptables

For good security measure, it is crucial that you lockdown your services (or daemons) that are open for everyone to connect(e.g SSH, VNC) to yourself, or a set group of users.

It is very simple to do so. First, you may wish to check the rules of your iptables using

sudo iptables -S

If you have rules in the INPUT table in place already, and wish to flush(clear) them,

sudo iptables -F INPUT

Now to lockdown the service, in this case

iptables -I INPUT -p tcp -s <your ip> --dport <your port> -j ACCEPT
iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport <your port> -j DROP

So if I wish to lockdown my ssh at port 2201,

iptables -I INPUT -p tcp -s 107.256.256.256 --dport 2201 -j ACCEPT
iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 2201 -j DROP

Note: If you port forwarded, you will need to allow localhost(127.0.0.1) in place of <your ip>

Enjoyed the content ? Share it with your friends !