GitHub source project here
GitHub Gist source here.
The better way to build ssh for logging in cloud services (such as GitHub
,
GitLab
, Gitee
, Bitbucket
...), remote web server(Nginx
, Cloudflare Server
,
Apache
, IIS and Lighttpd
, Microsoft Internet Information Services
,
Sun Java System Web Server
and Jigsaw
), customer premises via git
is that just search "terminal log in github
" by Google search engine.
A better way to learn the terminal to log in to github is to read the
official github related documents.
firstly search just using native language,
secondly search just using english,
thirdly search just using third language,
As the saying goes, well-informed.
2.What is SSH
Secure Shell (SSH)
is a cryptographic network protocol for operating network
services securely over an unsecured network.
Typical applications include remote command-line, login, and remote command
execution, but any network service can be secured with SSH
.
SSH
provides a secure channel over an unsecured network by using a client
–server architecture, connecting an SSH
client application with an SSH
server.
The protocol specification distinguishes between two major versions, referred
to as SSH-1
and SSH-2
.
The standard TCP
port for SSH
is 22
.
SSH
is generally used to access Unix-like
operating systems, but it can also
be used on Microsoft Windows
.
Windows 10
uses OpenSSH
as its default SSH
client and SSH
server.
SSH
was designed as a replacement for Telnet and for unsecured remote shell
protocols such as the Berkeley rsh and the related rlogin and rexec protocols.
Those protocols send sensitive information, notably passwords, in plaintext,
rendering them susceptible to interception and disclosure using packet
analysis.
The encryption used by SSH
is intended to provide confidentiality and
integrity of data over an unsecured network, such as the Internet
.
The most effective and safest way to build SSH
is to refer to the search
engine to practice, and then use the search engine to find and solve
the problem.
I know, I'll have more than one GitHub
account, some are personal, others
are corporate. So I just create a directory /GitHub
in my current user
directory /Users/marryme
, before doing this, I need to enter the terminal.
Some use the default terminal Apple Terminal
, but I use iTerm
here.
when i'm in the terminal, just use this command to create the directory
/GitHub
:
mkdir GitHub
Also, use this command to enter the directory /Users/marryme/GitHub
:
cd /Users/marryme/Github
I know, I'll have more than one personal GitHub
accounts and more than one
corporate GitHub
accounts. Now I'll create a directory /Personal
and a
directory /Corporate
. Just use this command to create that directions:
mkdir Personal
mkdir Corporate
Now, I have more than one personal GitHub accounts. My personal Github
accounts Sofija
, Starla
, Sivert
. Enter my personal GitHub directory
/Personal
and create three personal GitHub accounts:
mkdir Sofija
mkdir Starla
mkdir Sivert
Now the simple roadmap of logging in GitHub via terminal using ssh and git.
Just use this command to enter my personal GitHub account directory /Sofija
:
cd /Users/marryme/GitHub/Personal/Sofija
SSH is to connect between my computer Git and my GitHub,so Enter the command
to create an SSH Key for my personal GitHub account Sofija:
ssh-keygen -t rsa -b 4096 -C "sofijapersonalgithub@gmail.com"
-t type
鍵の生成に使用する鍵のアルゴリズムを指定します。プロトコルバージョン 2 に指定可能な値は「rsa
」
または「dsa
」です。指定できる値は、「ecdsa
」、「rsa」または「dsa
」です
-b “Bits”
This option specifies the number of bits in the key. The regulations
that govern the use case for SSH may require a specific key length to be used.
In general, 2048 bits is considered to be sufficient for RSA keys.
-C comment
鍵ファイル内のコメントフィールドに情報を指定します。文字列に空白が含まれている場合、
引用符を使用します。鍵の作成時にコメントを指定していない場合、鍵の種類、作成者、日付、時刻を含
む既定のコメントが作成されます。
sofijapersonalgithub@gmail.com
is my email address
The terminal prompt is as follows:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/XXX/.ssh/id_rsa):
At this time, press Enter directly, and a public key named id_rsa will be created under
the path /Users/XXX/.ssh/
, which is not what I want.
Because I want to manage multiple ssh keys, this naming does not have any characteristics.
I will store sofija_personal_github_id_rsa
in /Users/user-name/.ssh/sofija_github_id_rsa
.
Enter the following command in the terminal:
/Users/user-name/.ssh/sofija_personal_github_id_rsa
It means that this is the key of my private github account, and then according to the terminal
prompt, enter and confirm the password, and it can be generated.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/XXX/.ssh/sofija_personal_github_id_rsa.
Your public key has been saved in /Users/XXX/.ssh/sofija_personal_github_id_rsa.pub.
The key fingerprint is:
eval "$(ssh-agent -s)"
> Agent pid 59566
Once you have created the above ssh key, you can start to manage it.
Enter the following command in the terminal to query the proxy of
the system ssh key:
ssh-add -l
If the system has set up a proxy, you need to delete:
ssh-add -D
All identities removed.
If prompted:
Could not open a connection to your authentication agent.
execute:
ssh-agent bash
SSH-Agent, a helper program,a key manager for SSH, a agent server.
But during the SSH handshake my computer local git as a client,
and GitHub ad a server.
Create a config configuration file in the /.ssh directory:
cd /Users/user-name/.ssh && vim config
Pay attention to the common commands of vim
or bash
:
-
Press the letter key "
i
" to edit mode; -
Press the return key "
esc
" + input the letter ":wq
": save and exit;
Edit and adding :
Host sofija_personal-github.com
Hostname github.com
User git
AddKeysToAgent yes
UseKeychain yes
IdentityFile /Users/marryme/.ssh/sofija_personal_github_id_rsa
Add the SSH private key to ssh-agent and store the passphrase in the keychain.
If you create a key with another name, or if you want to add an existing key
with another name, replace sofija_personal_github_id_rsa
in the command with
the name of the private key file.
ssh-add -K /Users/marryme/.ssh/sofija_personal_github_id_rsa
Check the proxy of the ssh key again:
ssh-add -l
4096 SHA256:............ /Users/marryme/.ssh/sofija_personal_github_id_rsa (RSA)
Notice: Update 1:20 EST Friday June 2 2023
if your remote repository Bitbucket
occurs:
SSH Host Key Rotation
IMPORTANT NOTICE: Bitbucket Cloud’s RSA SSH Host Key will be rotated on June 20, 2023 1700 UTC
You just need to replace the old Bitbucket's SSH host Key at your local laptop's ~/.ssh
with the New bitbucket SSH Host key, via command:
ssh-keygen -R bitbucket.org && curl https://bitbucket.org/site/ssh >> ~/.ssh/known_hosts
Notice: You do not need to generate a non-RSA type SSH key pair for Bitbucket, as Bitbucket still supports RSA type SSH key pairs for authentication. You just need to update the SSH Host Key for Bitbucket on your local machine.
Refer:SSH Host Key Rotation(Stack overflow).
I know, no matter I directly copy the public key file
sofija_personal_github_id_rsa.pub
via vim copying or changing the .pub
to .txt
, that all does not successfully add to GitHub SSH keys, Use the
cat
command to print out the just created ssh key in the terminal.
(After creating the local ssh key, I need to let github know that the ssh key
is myself, so I need to copy the generated ssh key, write it to github, and
enter it in the terminal under mac)
cat /Users/user-name/.ssh/sofija_personal_github_id_rsa.pub
copy the print to GitHub ssh key location
Check the proxy of the ssh key again:
ssh-add -l
4096 SHA256:............ /Users/marryme/.ssh/sofija_personal_github_id_rsa (RSA)
Enter the following verification command in the terminal. If it returns as follows,
the configuration is successful:
ssh -T git@sofija_personal-github.com
discover Terminal:
The authenticity of host 'github.com (xxx.xx.xxx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:XXXXxxxxXXXXxxxxXXXXxxxxXXXXxxxx.
Are you sure you want to continue connecting (yes/no)?
Please type "yes
".
Then success:
Warning: Permanently added 'github.com,xxx.xx.xxx.xx' (ECDSA) to the list of known hosts.
Hi Sofija! You've successfully authenticated, but GitHub does not provide shell access.
If that was in GitLab, then:
Warning: Permanently added 'gitlab.com,xxx.xx.xxx.xx' (ECDSA) to the list of known hosts.
Welcome to GitLab, @sofijapersonalgithub!
If that was in Bitbucket,then:
if you enter "ssh -T git@sofija_personal-bitbucket.com
", then:
`The authenticity of host 'bitbucket.com (xx.xxx.xx.x)' can't be established.`
`RSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.`
`Are you sure you want to continue connecting (yes/no)?`
please type "`yes`".
Then, successful:
`Warning: Permanently added 'bitbucket.com,xx.xxx.xx.x' (RSA) to the list of known hosts.`
`authenticated via ssh key.`
`You can use git to connect to Bitbucket. Shell access is disabled`
First, before uploading the repository, you need to create a github repository. After
logging in to your account, click +
next to the avatar and select New repository
to
create a personal repository.
You can first create an empty warehouse, public, without README.md,LICENSE, .gitignore
and .gitattributes.
Please remember the ssh-url(SSH Git Address) of the empty warehouse created.
If your GitHub repository are not empty or you firstly download GitHub
repository to your local workspace or Your GitHub has that repository but
your local workspace has not that repository, please use command the step
## 4.1
.
I need to enter my personal GitHub account directory.
cd /Users/user-name/GitHub/Personal/Sofija
Now I need to pull remote Repository:
git clone git@sofija_personal-github.com:SofijaPersonal/hello-world-debug-vscode.git
(git clone
only run once, once run git clone, then do not need to run git init
and git remote add origin git@sofija_personal-github.com:SofijaPersonal/hello-world-debug-vscode.git
)
git clone
will clone the remote repository to the local directory
/Users/marryme/GitHub/Personal/Sofija
via creating the directory
/Users/marryme/GitHub/Personal/Sofija/hello-world-debug-vscode
.
The created directory /Users/marryme/GitHub/Personal/Sofija/hello-world-debug-vscode
is that my created GitHub Repository just now.
And, the created directory /hello-world-debug-vscode
also include .git
.
Now I need to enter my local repository hello-world-debug-vscode
cd hello-world-debug-vscode
Configure the information of the git user of the current Repository.
If I do not configure the git user of the current Repository, then the user name
submitted to GitHub is the current user name of the computer;
for example,
the current user name of my computer is marryme
, if I do not configure the
user name of my current warehouse as Sofija
, then submit The name of the
Repository to GitHub is marryme
.
(I think a safe, convenient, and concise way to use git is to configure
different user names, emails, and passwords in each local Repository, so
that possible problems can be located in a certain Repository)
In the terminal, enter the following commands respectively to check the
partial configuration information of git in the current computer. If it
does not return, it means that there is no partial configuration.
If there is, you can see that the corresponding default account is that.
git config user.name
git config user.email
If the return is empty, it means that no partial configuration has been
performed, and the account name and email address of github can be
configured separately:
git config user.name "Sofija_Personal_GitHub"
git config user.email "sofijapersonal@gmail.com"
execute:
git config --list
You can view the specific configuration information of the current Repository.
The configuration viewed in the current Repository directory is the global
configuration + the local configuration of the current project. When using it,
the local configuration of the current Repository will be used first. If not,
the global configuration will be read.
Now we create README.md
and write "# hello-world-debug-vscode
":
echo "# hello-world-debug-vscode" >> README.md
Add the file README.md
that needs to be updated to the local git repository:
git add README.md
(git add <your file name>
: specify the class update)
(git add .
:All classes that need to be updated)
Check if the file to be uploaded is correct:
git status
Record this submission:
git commit -m "Create README.md"
Create main
branch, git workspace and move from master
branch to main
branch,
-m
attribute is used to rename the branch name without affecting the branch’s
history:
git branch -M main
Mention the main branch to the remote github repository, -u
attribute is used to
set the upstream tracking for the branch.:
git push -u origin main
The main here refers to the main
branch name, if it is another branch, fill in the
corresponding branch name.
Log in to github to view the submission results.
If your GitHub repository is empty, then just use the step 4.2
.
i need to create a directory /hello-world-debug-vscode
.Please remember every
GitHub Repository to create one directory, and i'm in the directory
/Users/marryme/GitHub/Personal/Sofija
, Now:
Update EST AM 03:32 May 30 Tuesday, in summary for Step 4.2
:
cd ~/GitHub/Personal/Sofija && mkdir hello-world-debug-vscode &&
cd hello-world-debug-vscode && touch README.md &&
echo "# hello-world-debug-vscode" >> README.md && git init &&
git config user.name "Sofija_Personal_GitHub" &&
git config user.email "sofijapersonal@gmail.com" &&
git add README.md && git commit -m "Create README.md" &&
git branch -M main &&
git remote add origin git@sofija_personal-github.com:SofijaPersonal/hello-world-debug-vscode.git
&& git push -u origin main
mkdir hello-world-debug-vscode && cd hello-world-debug-vscode
The same thing, create README.md
and write "# hello-world-debug-vscode
":
echo "# hello-world-debug-vscode" >> README.md
make this directory /hello-world-debug-vscode
Git Repository
git init
git init
only run once, that will create the local Git repository.
ALso, enter the following commands respectively to check the
partial configuration information of git in the current computer:
git config user.name
git config user.email
And, the account name and email address of github can be
configured separately:
git config user.name "Sofija_Personal_GitHub"
git config user.email "sofijapersonal@gmail.com"
To view the specific configuration information of the current Repository:
git config --list
Now, add the file README.md
that needs to be updated to the local git repository:
git add README.md
Please notice: git add/rm <file>
run every-time while changing files.
Never forget check if the file to be uploaded is correct:
git status
Record this submission:
git commit -m "Create README.md"
Once run git add/rm <file>
, must run git commit -m "XXXX"
.
It's time to create main
branch, git workspace and move from master
branch
to main
branch:
git branch -M main
git branch -M main
only run once, or git branch -M other-branch
.
Associate a remote library command. Fill in my github repository (repository)
after git@. After creating the repository in github, there are links to http
and ssh
. Origin
is the name I gave to this repository and can be customized.
git remote add origin git@sofija_personal-github.com:SofijaPersonal/hello-world-debug-vscode.git
"git remote add origin ssh-url
" is to connect between local repository and
remote repository, only run once.
Query whether the connection is successful:
git remote -v
But if you remote add Wrong address via url using "git remote add origin ssh-url
"
or you want to change the url address, you could use this command to
change the ssh-url
to the target address:
git remote set-url origin ssh-url
eg:
git remote set-url origin git@sofija_personal-github.com:SofijaPersonal/hello-world.git
Mention the main branch to the remote github repository:
git push -u origin main
"git push -u origin main
" or "git push
" run every-time once "git add/rm <file>
",
or run git push -u origin other-branch
.
Update Nov 21 2022 EST 21:04
If you use git push -u origin main
to mention the main branch to the remote
github repository, that may generate the problem:
Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
To fix the upstairs problem, firstly, using Git
try to connect the GitHub
via ssh
again, e.g: ssh -T git@sofija_personal-github.com
.
Also, GitLab
or Bitbucket
do the same.
Just use this to fix that via git pull --rebase && git push -u origin main
.
Or maybe you should check the connection of your network.
Notice:
If you just use rm file
on your local workspace with no committing that file,
then your local repository again has that file, your remote repository also has
that file. Just use git restore <file>...
to discard changes in working
directory, and your local workspace will display that file. Remember to check
the status of your repository's git via git status
. Also, if you delete some
files on your local workspace but not commit those to the local repository, you
should use git pull --no-rebase
to pull the remote repository. Finally, if
there are some code collision or conflict, you need to use some commands liking
git merge ...
.
It is necessary to consider logging into multiple GitHub accounts on the
same computer, as well as logging into the same github account on multiple
computers.
e.g: logging in GitHub(personal), GitHub(company), Cloud(company), Cloud
(personal),Blog(personal), BitLab, Bitbucket, Azure devops... via ssh on
a terminal.
one to log in through the terminal, and one to log in through the
GitHub client.
What if there are two GitHub accounts on the same computer?
Cancel the global setting, set the user name and password for each
warehouse separately: cancel global;
git config --global --unset user.name
git config --global --unset user.email
And, If the corresponding git repository is not specifically configured,
the git global configuration will be taken by default, that is, the
default global configuration account will be used for git submission.
At this time, we need to configure different warehouses accordingly.
We can cd to the root directory of the corresponding git repository and
execute local git configuration commands.
For example,
/Users/marryme/Github/Personal/Starla
is the root directory of another local git
repository hosted on the github platform. I can execute the following
commands:
cd /Users/marryme/Github/Personal/Starla
git config user.name
git config user.email
If the return is empty, it means that no partial configuration has been
performed. The account name and email address of github can be configured
separately:
git config user.name "Starla-Personal-GitHub"
git config user.email "starlapersonalgithub@example.com"
In the same way, under different git repositories, you can configure git
account names and git mailboxes for different platforms.
Although this seems troublesome, as long as the settings are completed,
as long as the path of the corresponding git repository is no longer
changed, there is no need to change the configuration.
Moreover, even if we did not cancel the default global git configuration,
After partial configuration, the latter will have a higher priority.
execute:
git config --list
You can view the specific configuration information of the current
warehouse, The configuration viewed in the current warehouse directory
is the global configuration + the partial configuration of the current
project, When using it, the local configuration of the current warehouse
will be used first, if not, the global configuration will be read.
Set up each repo's own user.email
git config user.email "sivertpersonalgitee@gmail.com"
git config user.name "Sivert_Personal_Gitee"
If there are two git accounts, they are github@example.com
and
gitee@example.com
. In order to submit git, we need to set the
corresponding ssh key, so each git account needs to create and manage
ssh key, add public key to git platform, configure file config, verify
ssh key.
A.Generating a new SSH key and adding it to the ssh-agent(Github Docs)
B.Adding a new SSH key to your GitHub account(Github Docs)
C.How to Work with GitHub and Multiple Accounts(Github Gist)
D.Using multiple github accounts with ssh keys(Github Gist)
E.How to manage multiple Github accounts on one machine
1.homebrew-core/Formula/sshtrix.rb:("SSH login cracker")
2.homebrew-core/Formula/sshguard.rb:("Protect from brute force attacks against SSH")
3.homebrew-core/Formula/ssh-vault.rb:("Encrypt/decrypt using SSH keys")
4.homebrew-core/Formula/ssh-copy-id.rb:("Add a public key to a remote machine's authorized_keys file")
5.homebrew-core/Formula/ssh-permit-a38.rb:("Central management and deployment for SSH keys")
6.homebrew-core/Formula/git-ssh.rb:("Proxy for serving git repositories over SSH")
8.homebrew-core/Formula/openssh.rb:("OpenBSD freely-licensed SSH connectivity tools")
9.homebrew-core/Formula/stormssh.rb:("Command-line tool to manage your ssh connections")
1.Your first time with git and github
3.Start using Git on the command line
4.How do I log in using the Git terminal?
5.How to switch git user at terminal?
7.An Intro to Git and GitHub for Beginners (Tutorial)
9.How to Install, Configure and Use GIT on Ubuntu?
2.【初心者向け】Gitのインストール方法をわかり易く解説(画面付き)
7.Gitをインストールしてみよう!Windows/Macどちらも丁寧に解説
8.WindowsにGitをインストールする手順(2021年12月更新)
10.はじめてでもOK!Gitをインストールする方法【初心者向け】
13.初心者でもWindowsやMacでできる、Gitのインストールと基本的な使い方
17.MacOS】Homebrew経由でGitをインストールする方法
1.git command line to log in to github for operation
2.Use GitHub to share on the terminal
3.DevOps uses terminal to configure GitHub account on Mac
4.git connection github summary
5.One computer to manage multiple Git accounts and SSH KEY
6.How to manage multiple Github accounts on one machine
7.Use SSH to connect to GitHub on Mac
8.Upload files to GitHub in MacOS
Oh shit. Northeastern young couple at home. I was so scared that I was afraid
of being broken in and raped! Hurry up to find a job, change the house to rent.
Ok, i'm fine.
While watching pornographic videos and masturbating with hands, the brain is
the most involved in this process. When watching pornographic videos, the
provocative body and exposed sexual organs will cause the brain to secrete
a large amount of dopamine.
And dopamine is a neurotransmitter, a chemical substance used to help cells
transmit impulses. It is related to human lust and feelings, and it transmits
excitement and happiness. In addition, dopamine is also associated with
various addictive behaviors.
At the same time, dopamine is a dopamine receptor stimulant, which can
excite adrenaline alpha and beta receptors, and can accelerate heart rate,
constrict blood vessels, and raise blood pressure. If it is secreted too much,
Then it may cause the heart rate to increase, the blood pressure to rise, it
may cause arrhythmia, paroxysmal tachycardia, paroxysmal atrial fibrillation,
paroxysmal atrial flutter, and the patient may also experience dizziness, and
may even occur Insomnia, dreaminess.
Dopamine appears in the forebrain and basal ganglia (Basal Ganglia). The basal
ganglia are responsible for processing fear emotions, but because of dopamine,
it replaces the feeling of fear.
Therefore, many people's addictive behaviors are caused by dopamine.
Excessive dopamine can also cause emotional problems, anxiety, fear and even
mild depression.