Skip to main content

Múltiplas contas de git via ssh como lidar com isso?

Eu estava tendo dificuldades para conciliar multiplas contas git com autenticação ssh no meu linux.
A resolução para isso é simples, basta criar um arquivo config no diretório ~/.ssh/

No arquivo config você irá dizer que para cada host XYZ deve ser utilizado a chave de autenticação ABC. Mas se você possui duas chaves de autenticação no mesmo host? Ou seja, o motivo é você possuir duas contas no github ou bitbucket, então você vai setar o hostname original do github ou bitbucket no seu arquivo ~/.ssh/config e fazer hostnames personalizados localmente.

Com o exemplo você vai entender melhor:

Meu arquivo ~/.ssh/config:

Host bitbucket.org-ovictoraurelio
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/id_bitbucket_ovictoraurelio
    IdentitiesOnly yes

Host bitbucket.org-outrovictor
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/id_bitbucket_outrovictor
    IdentitiesOnly yes


E a configuração ~/meuprojeto/.git/config

[core]
        repositoryformatversion = 0
[remote "origin"]
        url = git@bitbucket.org-ovictoraurelio:maintener/meuprojeto.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[user]
        email = meuemail@gmail.com

Perceba que a configuração de remote origin possui um host bitbucket.org-ovictoraurelio que graças ao arquivo ~/.ssh/config é traduziada para bitbucket.org pois lá temos configurada a opção HostName

Popular posts from this blog

Realizar INSERT INTO a partir de um SELECT (insert from select)

Exemplo de query que realiza a inserção em uma tabela apartir de uma query INSERT INTO blablas (id, name , created_by, created_at, updated_at) SELECT DISTINCT ff . blabla_id , CONCAT ( "blablaulário de com concat " , t . name ), 1 , "2022-10-26 14:31:47" , "2022-10-26 14:31:47" FROM blablas_fields ff INNER JOIN outro_blabla t on t . blabla_id = ff . blabla_id WHERE ff . blabla_id NOT IN ( select id from blablas f) GROUP BY ff . blabla_id Mais em:  https://www.w3schools.com/sql/sql_insert_into_select.asp

CyberPanel without port 8090 and with a hostname

HOW TO REMOVE PORT 8090 FROM CYBERPANEL   December 25, 2018    Usmannasir   Comments   4 Comments Many of the users have asked about removing port 8090 so that they can visit CyberPanel on a plain domain like  panel.cyberpanel.net . However, normally this is not possible because port 8090 is hardcoded into to LSCPD server which powers CyberPanel. (Hardcoded configurations are used to improve performance) Step 1: Create a Website for Hostname First, you need to decide the domain on which you want to access CyberPanel without the port being appended to it. We are going to use  https://switch.cyberpanel.net. Now  create a website  for this domain (hostname). Please make sure that A record of this domain already points towards your server. Step 2: Issue Hostname SSL We now need to issue  Hostname SSL  for the domain we choose above. In our example it is  https://switch.cyberpanel.net . Setup CyberPanel without ...