Arquivo da categoria: Ubuntu

Rails – Script de deploy in server ubuntu

echo “Configurando a linguagem”
sudo apt-get install language-pack-pt

echo “Configurando o relogio”
sudo apt-get update
sudo apt-get install tzdata
sudo dpkg-reconfigure tzdata

echo “Criando usuario deploy”
sudo adduser deploy

echo “Criando configuracoes SSH”
su deploy
ssh-keygen
ssh-copy-id deploy@SERVER_IP_ADDRESS
cat ~/.ssh/id_rsa.pub
exit
su – deploy
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
exit

echo “Liberando o SSH – PermitRootLogin yes | PasswordAuthentication yes”
sudo nano /etc/ssh/sshd_config
sudo service ssh restart
sudo usermod -a -G sudo deploy
exit

echo “Logando como deploy”
ssh deploy@SERVER_IP_ADDRESS

echo “Instalacoes”
sudo apt-get update
sudo apt-get install curl git-core nginx libpq-dev imagemagick -y

echo “Instalando o Ruby e Rails”
gpg –keyserver hkp://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install VERSAO
gem install rails -v VERSAO
gem install bundler -V

echo “Instalando o NodeJS”

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash – sudo apt-get install -y nodejs

echo “SHH do Bitbucket”
ssh -T git@bitbucket.org
ssh-keygen -t rsa
echo “Olhar aqui: https://confluence.atlassian.com/display/BITBUCKET/Use+deployment+keys”

echo “git clone”
git clone git@bitbucket.org:infarma/ecommerce.git

echo “Estruturar o disparo do capistrano”
cat ~/.ssh/id_rsa.pub | ssh -p your_port_num deploy@your_server_ip ‘cat >> ~/.ssh/authorized_keys’

echo “Atualizando”
cap production deploy:initial

echo “Ajustes no Nginx”
sudo rm /etc/nginx/sites-enabled/default
sudo ln -nfs “/home/deploy/apps/appname/current/config/nginx.conf” “/etc/nginx/sites-enabled/appname”
sudo service nginx restart

How to SSH into a Ubuntu server after getting a “permission denied (publickey)” error

Updating your SSH configuration to allow password authentication

  1. Once you’ve launched the console, it will ask you for your user name and password. If you had to reset your root password and are using your root user to log in, it will prompt you to create a new password by typing it twice.
  2. Once you are logged in, you will need to update your sshd_config file by typing:
vim /etc/ssh/sshd_config

or if you are accessing it with a non-root user with sudo privileges, type:

sudo vim /etc/ssh/sshd_config

3. From there, you want to type i for INSERT (to edit your file) and find the option that says PasswordAuthentication no and update it to

PasswordAuthentication yes 

Then, type:

esc

followed by:

:wq

to write and quit out of the file, followed by hitting enter.

https://medium.com/@hidace/how-to-ssh-into-a-digitalocean-server-after-getting-permission-denied-publickey-error-77b687c2880d