Script asking for confirmation despite using -y - bash

I am trying to develop a script to setup software and some firewall rules. This is run on a fresh VPS while connected via SSH as the root user.
There are 2 points in the script where it appears to ignore '-y'
First Item:
apt update && apt upgrade -y && apt autoremove -y && apt autoclean -y
Causes this prompt to occur: Restart services during package upgrades without asking? Which I would like to just automatically select Yes.
Second Item:
ufw allow 1635/udp
ufw allow ssh
ufw enable
Causes this prompt to occur: Command may disrupt existing ssh connections. Proceed with operation? Which I would also like to just automatically select Yes.
Any help would be much appreciated. This 2 are currently stopping it from being a completely hands-off setup process.

Solved!
First Item
Discovered it was the apt upgrade causing the GUI prompt.
This was resolved by updating it to: DEBIAN_FRONTEND=noninteractive apt upgrade -y
Second Item
Resolved by updating ufw enable to: yes | ufw enable

Related

Bash how to remove centos packages without manual intervention, uninstall SSM agent in amazon linux 2

I am spinning up and EC2 instance and I am s setting up data users where I am trying to remove ssm agent as below:
sudo yum erase amazon-ssm-agent –y
But the problem in the above code is, even though I have passed -y it doesn't get it apparently, because I am getting the below prompt (I logged in to the instance and tried the same commands I have put in the data user section):
Is there a workaround for this?
This is so strange, the character I have given for the -y is not the hypen. I could fixed that after retyping the -y
-y is an option and options go before the command. So it should be:
sudo yum -y erase amazon-ssm-agent

Connect to CentOS desktop (GUI) installed on Google cloud

I've installed Centos7 on the Google Cloud Platform, as you know there is just ssh option to connect to the machine.
Now I need to have access to its desktop(GUI) from my laptop (it's win10).
it's appreciated if anyone can help me.
Thanks in advance
you need to ssh login into your CentOS machine either from ssh button in Gcloud, or using the cloud shell:
gcloud compute ssh test-vws
then setup a password for your account:
sudo passwd `whoami`
After that, you will need to install a client that will allow you to navigate the GUI for your server.
again, on your server command line execute:
sudo yum -y update
sudo yum -y groupinstall 'Server with GUI'
once finished, follow this guige to install and setup Teradici Cloud Access Software (Remote Desktop Agent for CentOS).
Installing Teradici Cloud Access Software
On your virtual workstation, install the Teradici repositories:
sudo yum -y install https://downloads.teradici.com/rhel/teradici-repo-latest.noarch.rpm
Install Teradici Standard Agent for Linux:
sudo yum -y update
sudo yum -y install pcoip-agent-standard
Then you will have to register the Agent and create a firewall rule to allow the connection, just follow the guide, and your desktop connection will look like this:

How to fix docker vulnerabilities (USN-4048-1) in ubuntu 18.08 LTS

I have AWS EC2 ubuntu 18.04 LTS machine. I want to fix the docker vulnerabilities (USN-4048-1).
Installed package : docker.io_17.03.2-0ubuntu7~ppa1
Fixed package : docker.io_18.09.7-0ubuntu1~18.04.3
How can i do that ? What's the steps to fix it ?
The simple way is to follow below step:
If the update-notifier-common package is installed, Ubuntu will alert you about pending updates via the message of the day (motd) upon console or remote login.
After logging in, you can check for and apply new updates with:
When performing an update, first review what apt is going to do, then confirm that you want to apply the updates (this is particularly true when running the development release).
If you would prefer to have updates applied automatically, make sure the unattended-upgrades package is installed, then run 'sudo dpkg-reconfigure unattended-upgrades'. Please note that updates may restart services on your server, so this may not be appropriate for all environments.
$ sudo apt-get update
$ sudo apt-get dist-upgrade
source : https://wiki.ubuntu.com/Security/Upgrades?_ga=2.36307296.1783287754.1567592268-1506938917.1567592268

How to upgrade ubuntu server to desktop in Amazon AWS? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have used an instance with ubuntu-server of AWS and would like to use GUI either so I did the following operations referring,
https://aws.amazon.com/premiumsupport/knowledge-center/connect-to-linux-desktop-from-windows/
How To Set Up GUI On Amazon EC2 Ubuntu server
It could be summarized as following.
a) Installed ubuntu-desktop and vnc4server
b) Changed the security settings in AWS console to open the ports 5901, 5902
c) Changed the security settings in my computer to open the ports for outbounding
However, connecting to the ubuntu it works but I could see only the screen full with a gray color.
What should I do further?
Boot up EC2 - Ubuntu 14.04 (LTS)
Once the instance is all boot up, update it:
sudo apt-get update
sudo apt-get upgrade
sudo vim /etc/ssh/sshd_config
Change PasswordAuthentication no to PasswordAuthentication yes
Restart SSH: sudo /etc/init.d/ssh restart OR sudo /etc/init.d/sshd restart
Go into root: sudo -i
Set password for ubuntu: passwd ubuntu
Once you've finished setting your password, go back to ubuntu user: su ubuntu & cd
Install Ubuntu desktop functionality:
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get update
sudo -E apt-get install -y ubuntu-desktop
Install XRDP and XFCE4:
sudo apt-get install xfce4 xrdp
sudo apt-get install xfce4 xfce4-goodies
Make XFCE4 the default for RDP connections:
echo xfce4-session > ~/.xsession
Copy .xsession to the /etc/skel folder so xfce4 is set as the default window manager for any new user accounts that are created.
sudo cp /home/ubuntu/.xsession /etc/skel
Allow host port to connect to xrdp.ini:
sudo vim /etc/xrdp/xrdp.ini
Change port=-1 to port=ask-1
Restart xrdp:
sudo service xrdp restart
Go back to AWS and make sure your security group includes inbound access to RDP 3389
Go into Microsoft Remote Desktop, type in your IP address with: XX.XX.XXX.XX:3389
Check this link - and this Untested but Solutions to 14.x to 15.x:
Update/upgrade with:
sudo do apt-get update
sudo apt-get dist-upgrade
sudo do-release-upgrade
Make it short and simple:
apt-get update –y
apt-get upgrade –y
apt-get install ubuntu-desktop xfce4 firefox
apt-get install xrdp
echo xfce4-session >~/.xsession
Below lines will solve your problem
THE FIX: edit /etc/xrdp/startwm.sh
make the last two lines look like this;
#. /etc/X11/Xsession
. /usr/bin/startxfce4
NOTE: Don't forget to create new users with password. Extremly necessary.
With this you can simply RDP(Remote Desktop) to the Ubuntu GUI machine.
Donot forget to open ports in Security Groups and Firewall if any implemented.

Clamav installation steps for linux centos

I have tried to install clamav in linux centos, but not able to succeed, so anybody provide me the procedure to install clamav antivirus and test the same.
Thanks in advance
First thing to do is install the program sudo apt-get install clamav
It´s necessary install the deamon program as well sudo apt-get install clamav-daemon
Once that we have the program properly installed, will be necessary configure to make it works with our app. /etc/clamav/clamd.conf
TCPAddr 127.0.0.1
TCPSocket 3310
To configure by console the antivirus just type sudo dpkg-reconfigure clamav-freshclam
Restart the service sudo /etc/init.d/clamv-* restart
For CentOS 6
Install ClamAV via yum epel repo:
yum install clamd
Edit config file:
vim /etc/clamd.conf
ExtendedDetectionInfo yes
ExcludePath /usr/local/maldetect/
DetectPUA yes
Set to start on boot:
chkconfig clamd on
Update ClamAV prior to a scan:
freshclam
Start ClamAV:
service clamd start
Add the cron for daily automatic scans:
vim /etc/cron.daily/daily-clamscan
#!/bin/bash
SCAN_DIR="/"
LOG_FILE="/var/log/clamav/daily-clamscan.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
Set proper cron permissions:
sudo chmod +x /etc/cron.daily/daily-clamscan
Update the logrotate file to look for all logs via wildcard
vim /etc/logrotate.d/daily-clamscan
/var/log/clamav/daily-clamscan.log {
missingok
notifempty
create 644 clam clam
}
Thats how I installed it on my machine. Here are a few good quick commands or you can use the cron to manually run it. I also installed Linux Malware Detect (LMD) with it so I can do more for my scans.
Full System Scan that only displays infected files and runs in the background with bell
Use jobs command to view status
clamscan -r --bell -i / &

Resources