A
A
Alex2015-07-11 13:39:10
git
Alex, 2015-07-11 13:39:10

How to push to github without entering login and password every time?

Maybe you need to somehow set up a github account or my git?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Gozhiy, 2015-07-16
@Kozack

A short manual on SSH + GitHub & BitBucket (on Win, almost the same on Lin)
First you need to find the keys

$ ls -al ~/.ssh
# Спискок файлов в директории .ssh, если они есть
# id_rsa.pub # Нам интересны эти два брата, точнее этот публичный код (паб)
# id_rsa # Это для сверки с пабом

If they are not there, then we will generate, after which they will kindly ask for a password, it should be complex, in the end it will be entered only once at the start of the session.
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
# Enter passphrase (empty for no passphrase):
# Enter same passphrase again:

By the way, you can change the password:
$ ssh-keygen -p # Введете старый, а потом новый.
The console will display the following:
# Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]

Now you need to add your keys to the ssh agent
Make sure you have it - run
$ ssh-agent -s
There should be the following one-line (!) output, the pid number will be different, everything else is from the evil one:
Agent pid 59566
If not, then most likely another shell in the terminal, then:
$ eval $(ssh-agent -s)
Agent pid 59566

Now you can add keys to the ssh agent
$ ssh-add ~/.ssh/id_rsa
Next, add the keys to the github and bitbucket VCS services, to do this, copy the contents of id_rsa.pub , and paste it in your VCS account settings (for example, "SSH and GPG keys" for Github). Activate keys.
for github:
$ ssh -T [email protected]
slightly longer, for bitbucket, you first need to create a config file, ~/.ssh/config , where add the following lines:
Host bitbucket.org
IdentityFile ~/.ssh/id_rsa # Тут приватный ключ!

Then run the following command:
$ ssh -T [email protected]
In each case, if everything goes well, you will receive the following messages:
Hi #{username}! You've successfully authenticated, but GitHub does not provide shell access.

or
conq: logged in as tutorials.
You can use git or hg to connect to Bitbucket. Shell access is disabled.

By the way, that Github, that Bitbucket gave me this time this:
Thу authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is 12:12:12...12.
Are you sure want to conecting (yes/no)?

Answered yes, the console answered something and everything works.
If you use aliases for hosts, then activation must be through an alias:
$ ssh -T [email protected]
If you work with Sourcetree (I recommend for Windows), then there is such a moment that the program does not accept the standard format of these keys and in order to work with the program via ssh, you will have to generate them from the received key (private) in a different format understandable by putty. To do this, use the puttygen program. Which is included in the supply of Sourcetree.

It's boring, but the end is near, then we need to set up ~/.bashrc, which is not on Windows, it will contain the initialization settings for the console and run the ssh agent, which will include your keys, remember the session:
# Note: ~/.ssh/environment should not be used, as it
#       already has a different purpose in SSH.

env=~/.ssh/agent.env

# Note: Don't bother checking SSH_AGENT_PID. It's not used
#       by SSH itself, and it might even be incorrect
#       (for example, when using agent-forwarding over SSH).

agent_is_running() {
    if [ "$SSH_AUTH_SOCK" ]; then
        # ssh-add returns:
        #   0 = agent running, has keys
        #   1 = agent running, no keys
        #   2 = agent not running
        ssh-add -l >/dev/null 2>&1 || [ $? -eq 1 ]
    else
        false
    fi
}

agent_has_keys() {
    ssh-add -l >/dev/null 2>&1
}

agent_load_env() {
    . "$env" >/dev/null
}

agent_start() {
    (umask 077; ssh-agent >"$env")
    . "$env" >/dev/null
}

if ! agent_is_running; then
    agent_load_env
fi

# if your keys are not stored in ~/.ssh/id_rsa or ~/.ssh/id_dsa, you'll need
# to paste the proper path after ssh-add
if ! agent_is_running; then
    agent_start
    ssh-add
elif ! agent_has_keys; then
    ssh-add
fi

unset env

And again, not the final, most likely since you did not use SSH, then your already existing local repos will work on http / https, so you need to change the addresses. Addresses of remote repositories are checked with the command $ git remote -v. To change git addresses, there is a special command: $ set-url, enter the following:
$ git remote set-url origin [email protected]:USERNAME/OTHERREPOSITORY.git

You can return everything to your homeland in the same way

4
4ainik, 2016-11-01
@4ainik

Linuxoids are so harsh that they hammer nails with calipers :)
here is a ruby ​​script that allows you not to enter login / password every time

f = IO.popen("git push origin master", 'r+')
f.puts ""
f.puts ""
sleep(10)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question