CentOS 7.x Migrate ssh based file sharing server
From Notes_Wiki
<yambe:breadcrumb self="Migrate SSH based file sharing server">CentOS_7.x_New_machine_configuration|New machine configuration</yambe:breadcrumb>
CentOS 7.x migrate ssh based file sharing server
If there is file sharing server on public cloud such as AWS EC2 where files are transferred using ssh/sftp/rsync etc. then to migrate such server to new instance use following steps:
- Create instance with public SSH enabled from any IP
- In case of AWS ensure that public IP does not change on shutdown/power-on via Elastic IP
- Connect to instance using downloaded keypair:
- ssh -i <> centos@<ip>
- Get root terminal and install vim
- sudo su -
- yum -y install vim
- Allow key based access to root user using 'vim ~/.ssh/authorized_keys' from
- Downloaded key pair (Note 155x)
- Personal SSH key pair
- Backup server SSH key pair
- Older server being migrated
- Change hostname of the new VM
- vim /etc/hostname
- hostname
- Copy /etc/shadow, /etc/passwd, /etc/group from old server to new OR create the user account again on new server with same password
- Enable password based SSH using 'vim /etc/ssh/sshd_config' and update
- PasswordAuthentication yes
- Restart SSH for changes to take effect
- systemctl restart sshd
- Setup CentOS 7.x fail2ban
- Rsync files from older server to new server
- rsync -vaHz --delete /home/ root@<new-ip>:/home/
- After this do 'ls -al /home' on new server and ensure all UID/GID got migrated successfully
- Shutdown older server
- Update DNS entry, if any, to point to new server public (elastic) IP
- CentOS 7.x adding swap space using file
<yambe:breadcrumb self="Migrate SSH based file sharing server">CentOS_7.x_New_machine_configuration|New machine configuration</yambe:breadcrumb>