IT Daily Documentation

Unable to push repo using bitbucket in CentOS 7

Problem: try to use git to push my repo in CentOS 7. But pop up below error message:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Solution: Go to Bitbucket panel, go to the SSH keys page in Personal Setting (not repo setting) and add the public key content.

Then upload the private key to your CentOS 7 server and enter below command:

eval `ssh-agent`
ssh-add <private_key_file>

remember the key file permission (600), and if you don’t want to run above command every time you log in. you can run ssh-agent on the background.

eval $(ssh-agent -s)

then enter below command --

ssh -T [email protected]

above command is to verify your configuration and Bitbucket username. If you see below message then you can start to push your repo.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

You can push your code using

git push

Laravel with Nginx config file example

Just for my reference.

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name localhost;

    location / {
            try_files $uri $uri/ =404;
    }
}

Redirect ip website using Nginx configuration

Want to prevent other visitor can view the ip website (e.g xxx.xxx.xxx.xxx/test_website), because it just for local test.

Solution:

add below script into server{}

set $allow 0;
if ($remote_addr ~ "your allowed ip 1") { set $allow 1;}
if ($remote_addr ~ "your allowed ip 2") { set $allow 1;}
if ($remote_addr ~ "your allowed ip 3") { set $allow 1;}

if ($allow ~ 0) {
	rewrite ^ https://www.google.com;
}

Use ssh-agent to save ssh passphrase in Window 10

Ref: https://stackoverflow.com/a/52113739

Ref: https://stackoverflow.com/a/18683544

Problem: When using SSH to connect other server, I don’t want to type passphrase everytime:)

For Windows 10 you need PowerShell to active ssh-agent in order to save passphrase.

Solution: First use Administrator right to open PowerShell (Windows PowerShell).

Then enter below command to active ssh-agent:

local Administrator PowerShell 
Set-Service ssh-agent -StnartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent

Then now you can add the key file (My file store in C:\Users\user.ssh\id_rsa), it will prompt a message to obtain the passphrase.

ssh-add C:\Users\user.ssh\id_rsa
(Enter your passphrase)

Eventually, ssh-agent will store your passphrase now. You can also enter

ssh-add -l

to check out the record.