def deploy_ssh(refresh_key=False): deploy_base_user_ssh() sudo("mkdir -p /etc/ssh/key/") sudo("chmod 755 /etc/ssh/key") run("mkdir -p /tmp/config/") sudo("cp /etc/ssh/ssh_host_{rsa,dsa,ecdsa,ed25519}_key*] /etc/ssh/key/ ||echo do not find") if refresh_key: sudo('rm -f /etc/ssh/key/*') sudo('yes y|ssh-keygen -b 4096 -t rsa -N "" -f /etc/ssh/key/ssh_host_rsa_key') sudo('yes y|ssh-keygen -t dsa -N "" -f /etc/ssh/key/ssh_host_dsa_key') sudo('yes y|ssh-keygen -b521 -t ecdsa -N "" -f /etc/ssh/key/ssh_host_ecdsa_key') sudo('yes y|ssh-keygen -b 9192 -t ed25519 -N "" -f /etc/ssh/key/ssh_host_ed25519_key') config("config/ssh/sshd_config", "/etc/ssh/sshd_config") sudo("service ssh restart") sudo('rm -f /etc/ssh/ssh_host_{rsa,dsa,ecdsa,ed25519}_key*]')
def deploy_base(): install(['sudo', 'vim', 'zip']) config('config/vim.conf', '/etc/vim/vimrc') config('config/ssh/ssh_config', '/etc/ssh/') sudo('mkdir -p /etc/bashrc.d/') config('config/bashrc.d/prompt.sh', '/etc/bashrc.d/') put("config/bashrc_init.inject", "/tmp/") sudo("grep A3BE697D-5DC6-4D06-A24D-64C796B6677C /etc/bash.bashrc " "|| cat /tmp/bashrc_init.inject >> /etc/bash.bashrc " "&& echo inject bashrc loader!!!") deploy_script()