Git相关

2020.7.7号

记录下

公司的github是内网,登录进去:http://192.168.30.67:8082/

Git相关_第1张图片

 本地下载git安装,设置用户名和邮箱,这个以前记录过:https://blog.csdn.net/qq_38663663/article/details/106430885

生成秘钥放入网站中

git clone ssh://[email protected]:2222/yhy/tutorial.git

使用git将本地项目推送到码云私有仓库

1、打开Git Bash

2、初始化:   

git init

3、新建仓库,复制ssh

4、在本地库上使用命令git remote add把它和远程库关联:

git remote add dev ssh://[email protected]:2222/jiaxuan/hpc.git

5、查看是否关联:

git remote -v

如果需要删除使用

git remote remove 

6、第一次执行

git pull

7、将项目添加到本地仓库中

git add  .

8、查看一下git状态,看是否添加成功

git status

9、commit到本地仓库

git commit -am "提交时描述信息"

10、 将本地代码push到master主分支上

git push -u -f dev master

11、切换分支以及提交指定文件

git checkout dev

git add 文件名称
git commit -m"描述信息"

补充点:

压缩:tar zcvf    /home/pkgs.tar.gz archives/

解压:tar -xzvf file.tar.gz //解压tar.gz

 

记录下今天写的自动化脚本

1、modifyhostname(批量生成ip和主机名,实现SSH免密登录,再批量修改hosts)

#!/bin/bash
# FileName:             ip.sh
# Version:              0.1
# Date:                 2020-07-6
# Author:               JX
# Description:          Batch modify host name

export PATH=$PATH
net=192.168.1.
SNAMEPRE=ubuntu
USER=root
PASSWD=jiaxuan 

#generate IP address 
touch ./host.txt
for i in `seq 10`                 
do
echo $net$i $SNAMEPRE$i >> ./host.txt        
done
echo "Completed generate IP address!"
cat ./host.txt  >>  /etc/hosts

#SSH free login  and  modify host name
echo "Perform detection and install expect module"
ep=`ls /usr/bin | grep expect` 
if [ -z $ep   ] ; then
 echo "did not install the expect module, ready to perform the installation"
 sleep 2
 apt-get install tcl tk expect
else
 echo "installed. After 1 second, the ssh file synchronization starts."
 sleep 1
fi

if [ ! -f ~/.ssh/id_rsa ];then
 echo "Need to create a key"
 ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
else
 echo "The key already exists"
fi
for i in {1..3};
do /usr/bin/expect << EOF   
spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $USER@$SNAMEPRE$i
expect {
"(yes/no)?" {send "yes\r";exp_continue}
"password:" {send "$PASSWD\r"}
}
interact
expect eof
EOF
scp /etc/hosts $USER@$SNAMEPRE$i:/etc/hosts;
done;
echo "Completed modify host name!"

2、freelogin(ssh免密登录)

#!/bin/sh
# FileName:             freelogin.sh
# Version:              0.1
# Date:                 2020-07-6
# Author:               JX
# Description:          ssh password-free login
SERVERS="ubuntu1 ubuntu2 ubuntu3"
PASSWORD=jiaxuan

echo "Perform detection and install expect module"
ep=`ls /usr/bin | grep expect` 

if [ -z $ep   ] ; then
 echo "did not install the expect module, ready to perform the installation"
 sleep 2
 apt-get install tcl tk expect
else
 echo "installed. After 1 second, the ssh file synchronization starts."
 sleep 1
fi

if [ ! -f ~/.ssh/id_rsa ];then
 echo "Need to create a key"
 ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
else
 echo "The key already exists"
fi

auto_ssh_copy_id() {
 expect -c "set timeout -1;
 spawn ssh-copy-id $1;
  expect {
    *(yes/no)* {send -- yes\r;exp_continue;}
    *assword* {send -- $2\r;exp_continue;}
     eof {exit 0;}
  }";
}
ssh_copy_id_to_all() {
    for SERVER in $SERVERS
    do
        auto_ssh_copy_id $SERVER $PASSWORD
    done
}
ssh_copy_id_to_all
echo "Completed node 1 login to node 2/3"

ssh_send(){
    for S in $SERVERS
    do
        scp /root/.ssh/id_rsa  root@$S:/root/.ssh
    done
}
ssh_send
echo "The secret-free login has been completed"


 

你可能感兴趣的:(linux)