can't push to github repo after replasing to another PC

909 views Asked by At

I was starting my project and used github for remote repo.

I changed my OS from Ubuntu to Xubuntu.

But I copied all my old files to the new location.

I keep working with my program I need to push changes.

I generated new SSH key and added to github.

I tried to push changes but it prints strange info:

nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ sudo git push -u origin master
[sudo] password for nazar:
ssh: Could not resolve hostname github.com: Name or service not known
fatal: The remote end hung up unexpectedly

Update:

I recreated this project again, and now it asks me about my passphrase:

nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ git commit -m "correct smole issue"
[master e2cbdec] correct smole issue
 1 file changed, 29 insertions(+), 29 deletions(-)
 rewrite README.md (89%)
nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ git push
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
Enter passphrase for key '/home/nazar/.ssh/id_rsa': 
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 843 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To [email protected]:nazar-art/NewYearGift.git
   3fb0853..e2cbdec  master -> master

Now it works but why so strict?

Can smb explain?

How to solve this trouble?

3

There are 3 answers

4
Chris On BEST ANSWER

When you create an SSH key you have the option to add a passphrase to it. This is not mandatory, but it does provide an added layer of security.

You are being prompted for a passphrase because your key has has one.

It is possible to remove the passphrase if you want, but I'd recommend using an agent instead. When using an agent, you can give your passphrase once and you won't be promoted to enter it again for a certain amount of time.

Depending on your operating system and desktop environment you have a number of options for running an agent. OpenSSH provides this method:

ssh-add -t 5h

This will prompt you for your passphrase immediately, and then let you work for five hours without having to re-enter your passphrase. See the manpage for details.

The time formats understood by OpenSSH can be found in the manpage for sshd_config.

0
ThiefMaster On

Could not resolve hostname github.com: Name or service not known

You need to fix your system's resolver. For some reason it cannot resolve the IP address for github.com

0
VonC On

Make sure your ssh url isn't an one using an scp syntax:

github.com:username/yourRepo

Because if it is, ssh will look for an ~/.ssh/config file to resolve "github.com"

Host github.com
  HostName github.com
  User git

You can use the original ssh url:

git remote set-url origin ssh://[email protected]/username/yourRepo.git

You could also try and switch to an https url

git remote set-url origin https://[email protected]/username/yourRepo