• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

local

SFTP Command Line

February 6, 2022

Here are command lines you can within SFTP.

Login.

sftp username@servername

sftp username@servername

Commands available from the local client.

lls
lcd
lmkdir
lpwd
lumask

lls lcd lmkdir lpwd lumask

Commands available on remote server.

cd
chmod
chown
exit
get
help
ln
ls
mkdir
put
pwd
rename
rm
rmdir
version
!

cd chmod chown exit get help ln ls mkdir put pwd rename rm rmdir version !

Filed Under: Linux Tagged With: commands, local, remote, sftp

Create Local Repo in Rocky Linux 8

January 30, 2022

How to create a local repo in Rocky Linux 8.

Install nginx. Enable service.

dnf install nginx
systemctl enable nginx --now
systemctl status nginx

dnf install nginx systemctl enable nginx --now systemctl status nginx

Create repo.

dnf repolist
dnf install createrepo yum-utils
mkdir /usr/share/nginx/html/repos
mkdir -p /usr/share/nginx/html/repos/{baseos,appstream}

dnf repolist dnf install createrepo yum-utils mkdir /usr/share/nginx/html/repos mkdir -p /usr/share/nginx/html/repos/{baseos,appstream}

Sync repos.

dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata
dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata
createrepo /usr/share/nginx/html/repos/baseos/
createrepo /usr/share/nginx/html/repos/appstream/

dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata createrepo /usr/share/nginx/html/repos/baseos/ createrepo /usr/share/nginx/html/repos/appstream/

Create cron to sync repos daily. Create file called /etc/cron.daily/update-localrepos

#!/bin/bash
/bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata
/bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata
/usr/bin/createrepo /usr/share/nginx/html/repos/baseos/
/usr/bin/createrepo /usr/share/nginx/html/repos/appstream/

#!/bin/bash /bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata /bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata /usr/bin/createrepo /usr/share/nginx/html/repos/baseos/ /usr/bin/createrepo /usr/share/nginx/html/repos/appstream/

Create a file called /etc/nginx/conf.d/repos.conf.

server {
        listen   80;
        server_name  reposerver.example.com;
        root   /usr/share/nginx/html/repos;
	index index.html; 
	location / {
                autoindex on;
        }
}

server { listen 80; server_name reposerver.example.com; root /usr/share/nginx/html/repos; index index.html; location / { autoindex on; } }

Restart nginx.

systemctl restart nginx

systemctl restart nginx

Configure firewall and SELinux.

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload
getenforce
chcon -Rt httpd_sys_content_t /usr/share/nginx/html/repos/

firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --reload getenforce chcon -Rt httpd_sys_content_t /usr/share/nginx/html/repos/

Move existing repos to /tmp.

mv /etc/yum.repos.d/*.repo /tmp/

mv /etc/yum.repos.d/*.repo /tmp/

Create a new repo called /etc/yum.repos.d/localrepo.repo

[localrepo-base]
name=RockyLinux Base
baseurl=http://reposerver.example.com/baseos/
gpgcheck=0
enabled=1
[localrepo-appstream]
name=RockyLinux Base
baseurl=http://reposerver.example.com/appstream/
gpgcheck=0
enabled=1

[localrepo-base] name=RockyLinux Base baseurl=http://reposerver.example.com/baseos/ gpgcheck=0 enabled=1 [localrepo-appstream] name=RockyLinux Base baseurl=http://reposerver.example.com/appstream/ gpgcheck=0 enabled=1

Clean cache and check repolist.

dnf clean all 
dnf repolist

dnf clean all dnf repolist

Edit /etc/hosts and add reposerver.example.com. Add it to other hosts.

echo "10.10.10.10        reposerver.example.com     reposerver" >> /etc/hosts

echo "10.10.10.10 reposerver.example.com reposerver" >> /etc/hosts

Finally, run yum install against the local repo. Installing lvm in this example.

yum install lvm2

yum install lvm2

Filed Under: Linux Tagged With: create, local, repo, rocky linux 8

Yum localinstall

December 24, 2020

Here’s how to install a RPM locally. Download the RPM first.

wget https://domain.com/path/to/file/rpmfile1.rpm
wget https://domain.com/path/to/file/rpmfile2.rpm

wget https://domain.com/path/to/file/rpmfile1.rpm wget https://domain.com/path/to/file/rpmfile2.rpm

Then install RPM from a local file.

yum localinstall /path/to/rpmfile1.rpm
yum localinstall /path/to/rpmfile2.rpm

yum localinstall /path/to/rpmfile1.rpm yum localinstall /path/to/rpmfile2.rpm

Filed Under: Linux Tagged With: install, local, rhel, rpm, yum

GCP Load Balancer Local Routing Table

July 29, 2019

Test if the GCP Load Balancer is working by sending a curl command from the backend VM.

Assume the load balancer IP address is 10.1.2.99, and the VM is called vm-a1.

curl http://10.1.2.99

curl http://10.1.2.99

The end result is …

Page served from: vm-a1

Page served from: vm-a1

Make sure there’s an entry in the local table that matches the IP of the load balancer.

ip route show table local | grep 10.1.2.99

ip route show table local | grep 10.1.2.99

If not, add it.

ip route add to local 10.1.2.99/32 dev eth0 proto 66

ip route add to local 10.1.2.99/32 dev eth0 proto 66

Documentation

Filed Under: Cloud, Linux Tagged With: curl, gcp, load balancer, local, route, table

  • Home
  • About
  • Archives

Copyright © 2023