github
connecting-to-github-with-ssh
- Creating SSH keys can be found at learning -> linux server -> adding ssh keys
Adding public key to github account
- Copies the contents of the id_rsa.pub file to your clipboard
- In GitHub, In the upper-right corner of any page, click your profile photo, then click Settings.
- In the user settings sidebar, click SSH and GPG keys.
- Click New SSH key or Add SSH key.
- In the "Title" field, add a descriptive label for the new key. (Say My Laptop Key)
- Paste your key into the "Key" field.
Test SSH connection
//Attempts to ssh to GitHub , for more verbose output use -vT
ssh -T git@github.com
//type yes
Are you sure you want to continue connecting (yes/no)? yes
Note:
- If machine has https (certificate) enabled, then it wont ping github.com.
//add the following content in ~/.ssh/ssh_config (centos) or ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
Points
- Organization settings -> Member privileges -> Base permissions -> None (by default no permission to user on any repos)
Other Ref
- https://help.github.com/en/enterprise/2.20/admin/user-management/using-ldap
- https://help.github.com/en/enterprise/2.20/admin/user-management/organizations-and-teams
Using Github Developer API
Create a token for API authentication
- Go to github account settings -> developer settings -> personal access tokens -> New token & give respective API access like repo group, admin-read option..etc
Repo APIs
Get all organization repo details
GET https://api.github.com/orgs/MyOrgName/repos
With following header
Authorization "token generatedTokenValue"
output
[{
"id": "",
"name": "great-public",
"full_name": "MyOrgName/great-public",
"private": false,
"owner": {
"login": "",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/MyOrgName/great-public",
"tags_url": "https://api.github.com/repos/MyOrgName/great-public/tags",
"comments_url": "https://api.github.com/repos/MyOrgName/great-public/comments{/number}",
"downloads_url": "https://api.github.com/repos/MyOrgName/great-public/downloads",
"git_url": "git://github.com/MyOrgName/great-public.git",
"ssh_url": "git@github.com:MyOrgName/great-public.git",
"clone_url": "https://github.com/MyOrgName/great-public.git",
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"open_issues_count": 0, "
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
..so on
}
]
Multiple github accounts in same machine with ssh keys
- ref
- for public repos, can clone & then specify folder level email & name but private repos won't clone
~/.ssh/config
# Personal GitHub account
Host office-github
HostName github.com
User myNameX
IdentityFile ~/.ssh/github_id_rsa
# Work GitHub account
Host pers-github
HostName github.com
User myNameY
IdentityFile ~/.ssh/github_per_id_rsa
//use
git clone git@pers-github:myNameY/my-repo.git
//instead
git clone git@github.com:myNameY/my-repo.git