Tag Archives: unix

[Solved] github Error: ERROR: You‘re using an RSA key with SHA-1

github Error: ERROR: You're using an RSA key with SHA-1,RSA can not used and need to upgrade:

ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

Solution:

# Generate a new secret key, if you report an error unknown key type ed25519, use this: ssh-keygen -t ecdsa -b 521 -C "[email protected]", all the way back to the car (the first carriage return is the name of the generated secret key, do not give the default, the last two are the password, you can do without)
$ ssh-keygen -t ed25519 -C "[email protected]"

# start ssh proxy, use different commands depending on the environment
$ eval "$(ssh-agent -s)"

# Add the secret key to the agent, and if there are other previous secret keys, add them too
$ ssh-add id_ecdsa

# View the secret key and copy and paste it to GitHub
$ cat ~/.ssh/id_ecdsa

# Test, it's best to pull a project to see if it can be accessed
$ ssh -T [email protected]

log

(pytorch) [yudong@admin1 Temp]$ git pull
ERROR: You are using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
# 生成秘钥
(pytorch) [yudong@admin1 .ssh]$ ssh-keygen -t ecdsa -b 521 -C "[email protected]"
Generating public/private ecdsa key pair.
Enter file in which to save the key (/public/home/yudong/.ssh/id_ecdsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /public/home/yudong/.ssh/id_ecdsa.
Your public key has been saved in /public/home/yudong/.ssh/id_ecdsa.pub.
The key fingerprint is:
7a:3b:30:d8:b5:a3:5d:c7:85:8b:82:b6:75:2a:d8:fc [email protected]
The key's randomart image is:
+--[ECDSA  521]---+
|                 |
|                 |
|             .   |
|        .   . .  |
|     o oS. o o   |
|    . *.= + +    |
|     =.B.* .     |
|    . *.+.       |
|       oE.       |
+-----------------+
(pytorch) [yudong@admin1 .ssh]$ ls
authorized_keys  config  id_ecdsa  id_ecdsa.pub  id_rsa  id_rsa.pub  known_hosts
# start shh proxy
(pytorch) [yudong@admin1 .ssh]$ eval "$(ssh-agent -s)"
Agent pid 210477
# add proxy
(pytorch) [yudong@admin1 .ssh]$ ssh-add id_ecdsa
Identity added: id_ecdsa (id_ecdsa)
(pytorch) [yudong@admin1 .ssh]$ ssh-add id_rsa
Identity added: id_rsa (id_rsa)
# check the public key
(pytorch) [yudong@admin1 .ssh]$ cat id_ecdsa.pub 
ecdsa-sha2-nistp521 AAAAE2VjZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXkfa6XXXqOS62um3j8ZOXVdabpGwCRCVBLlxMNfmNPRNG2FEl3rkxpw2O91MAINv+JiXPU56sA== [email protected]
# test
(pytorch) [yudong@admin1 .ssh]$ ssh -T [email protected]
Hi ydduong! You have successfully authenticated, but GitHub does not provide shell access.
(pytorch) [yudong@admin1 .ssh]$ cd ../Temp/
# test
(pytorch) [yudong@admin1 Temp]$ git pull
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 3), reused 6 (delta 3), pack-reused 0
Unpacking objects: 100% (6/6), done.
From github.com:ydduong/Temp
   5e7379d..aec2a53  main       -> origin/main
Updating 5e7379d..aec2a53
Fast-forward
 Snipaste_2022-03-25_23-26-58.png | Bin 0 -> 238594 bytes
 plt.py                           |  65 +++++++++++++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 49 insertions(+), 16 deletions(-)
 create mode 100644 Snipaste_2022-03-25_23-26-58.png
(pytorch) [yudong@admin1 Temp]$ 

[Solved] error LNK2005: ___pInvalidArgHandler Already defined in libcmtd.lib(invarg.obj)

Started generation...
1>------ has been started: Project: Bosch_EDC7, Configuration: Debug Win32 ------
1>edc7.lib(Bosch_EDC7.obj) : MSIL .netmodule or module compiled with /GL found; link is being restarted with /LTCG; adding /LTCG to link command line to improve linker performance
1>LINK : warning LNK4075: ignore "/INCREMENTAL" (due to "/LTCG" specification)
1>Bosch_EDC7.obj : warning LNK4075: ignore "/EDITANDCONTINUE" (due to "/OPT:ICF" specification)
1>LIBCMT.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __call_reportfault has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *, unsigned int,unsigned int)" (? _invoke_watson@@YAXPBG00II@Z) is already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter has been defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *, unsigned int,unsigned int)" (? _invalid_parameter@@YAXPBG00II@Z) is already defined in libcmtd.lib(invarg.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "public: static struct CRuntimeClass const CObject::classCObject" (?classCObject@CObject@@ 2UCRuntimeClass@@B) is already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "public: virtual struct CRuntimeClass * __thiscall CObject::GetRuntimeClass(void)const " (? GetRuntimeClass@CObject@@UBEPAUCRuntimeClass@@XZ) already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "public: class CObject * __thiscall CRuntimeClass::CreateObject(void)" (?CreateObject@ CRuntimeClass@@QAEPAVCObject@@XZ) already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "public: int __thiscall CObject::IsSerializable(void)const " (?IsSerializable@CObject@@QBEHXZ) already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "public: int __thiscall CRuntimeClass::IsDerivedFrom(struct CRuntimeClass const *)const " (? IsDerivedFrom@CRuntimeClass@@QBEHPBU1@@Z) already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "public: int __thiscall CObject::IsKindOf(struct CRuntimeClass const *)const " (?IsKindOf@CObject@@@ QBEHPBUCRuntimeClass@@@Z) is already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "class CObject * __cdecl AfxDynamicDownCast(struct CRuntimeClass *,class CObject *)" (? AfxDynamicDownCast@@YAPAVCObject@@PAUCRuntimeClass@@PAV1@@Z) already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(objcore.obj) : error LNK2005: "void __stdcall AfxClassInit(struct CRuntimeClass *)" (?AfxClassInit@@@YGXPAUCRuntimeClass@@@Z) already defined in nafxcwd.lib(objcore.obj)
1>nafxcw.lib(winmain.obj) : error LNK2005: "class CWinApp * __stdcall AfxGetApp(void)" (?AfxGetApp@@YGPAVCWinApp@@XZ) is already defined in nafxcwd.lib(afxinl2 .obj) is defined in
1>LINK : warning LNK4098: Default library "LIBCMT" conflicts with other libraries; please use /NODEFAULTLIB:library
1>LINK : warning LNK4098: The default library "nafxcw.lib" conflicts with other libraries; please use /NODEFAULTLIB:library
1>D:\A-Working\VS10_Projects\Bosch_EDC7\Bosch_EDC7\Debug\Bosch_EDC7.exe : fatal error LNK1169: One or more multi-defined symbols found
1> The operation to generate the project "Bosch_EDC7.vcxproj" has been completed - failed.
========== Generated: 0 successful, 1 failed, 2 latest, 0 skipped ==========

Solution:
The reason is that in Debug mode, some libraries are used in conflict, we just ignore the conflicting libraries.
Project Project Properties —> Linker —> Input —> Ignore specific default libraries —>

nafxcw.lib;libcmt.lib

What should be paid attention to in socket programming — bind socket error: address already in use

When programming Linux networks, you often encounter the following usage errors every time you modify the source code and compile it again:

Bind error: Address already in use

Although the process was forced to end with Ctrl+C, the error still exists. We can still see the process “forced to end” with Ctrl+C with netstat -an |grep 5120 and ps aux |grep 5120. The port is still in use, so we have to kill the process with kill every time, which is very troublesome. Last night, I happened to browse an article titled “5 Hidden Dangers in Linux Socket Programming” on THE IBM website. I suddenly realized that I had a try today and solved the problem as expected. I hereby express my thanks and hope that more coder can read this article and avoid making mistakes.

The main codes are:

int on;

on = 1;
ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, & on, sizeof(on) );
now every time I force the process to end with Ctrl+C, I can still see the port in use with netstat and ps, but the running program will not have the error of “Address already in use”, so the port is reused.

 

Here is the third pitfall in this article — incorrect address usage

Address usage error (EADDRINUSE)

You can use the Bind API function to bind an address (an interface and a port) to a socket endpoint. You can use this function in your server Settings to limit the interfaces that may have a connection coming. You can also use this function in client Settings to limit the interfaces that should be used for outgoing connections. The most common use of BIND is to associate a port number with a server and use a wildcard address (INADDR_ANY), which allows any interface to be used for incoming connections.

A common problem with BIND is trying to bind to a port that is already in use. The trap is that no active socket may exist, but the binding port is still disabled (bind returns EADDRINUSE), which is caused by the TCP socket state TIME_WAIT. This state remains for about 2 to 4 minutes after the socket is closed. After the TIME_WAIT state exits, the socket is deleted and the address can be rebound without problems.

Waiting for TIME_WAIT to end can be annoying, especially if you’re developing a socket server and need to stop the server to make some changes, and then restart. Fortunately, there is a way to get around the TIME_WAIT state. You can apply the SO_REUSEADDR socket option to the socket so that the port can be reused immediately.

Consider the example in Listing 3. Before binding the address, I call setsockopt with the SO_REUSEADDR option. To allow address reuse, I set the integer parameter (on) to 1 (otherwise, I can set it to 0 to prohibit address reuse).

use the SO_REUSEADDR socket option to avoid address usage errors

 

int sock, ret, on;
struct sockaddr_in servaddr;
/* Create a new stream (TCP) socket */
sock = socket( AF_INET, SOCK_STREAM, 0 ):
/* Enable address reuse */
on = 1;
ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, & on, sizeof(on) );
/* Allow connections to port 8080 from any available interface */
memset( & servaddr, 0, sizeof(servaddr) );
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl( INADDR_ANY );
servaddr.sin_port = htons( 45000 );
/* Bind to the address (interface/port) */
ret = bind( sock, (struct sockaddr *)& servaddr, sizeof(servaddr) );
after the SO_REUSEADDR option is applied, the bind API function allows immediate reuse of the address.

 

Five pitfalls in Linux socket programming
http://www.ibm.com/developerworks/cn/linux/l-sockpit/

[Fixed] Syntax error: word unexpected (expecting “)”)

mkdir.sh

Execute sh mkdir.sh XXX (argument)

Error: mkdirs.sh: 9: Syntax error: Word unexpected (“do”)
Syntax error: word unexpected (“)”)
Similar problems, the case see details
http://ubuntuforums.org/archive/index.php/t-1130892.html
http://forum.ubuntu.org.cn/viewtopic.php?f=21& t=416571

Summarize several questions:
1. dos2unix xxx
2. Sh mkdir.sh failed to run mkdir.sh directly
3. Modify the #!/bin/sh to #! /bin/bash, then execute bash mkdir.sh XXX
4. See if there are any errors in the syntax, if line wrapping is required; Etc.
5. For permission issues, try to implement a copy of cp
Ls-l look at the owner 

About Java File.separator

in Windows path separator and Linux path separator is different, when the absolute path is used directly, cross-platform will be exposed “No such file or diretory” exception.

File
File file1 = new File (“C:\ TMP \test.txt”);
File file1 = new File (“C:\ TMP \test.txt”)

File file2 = new File (“/ TMP /test.txt”);
File file2 = new File (“/ TMP /test.txt”);

if cross-platform is considered, it is best to say:
File myFile = new File(“C:” + file.separator + “TMP” + file.separator, “test.txt”);
File myFile = new File(“C:” + file.separator + “TMP” + file.separator, “test.txt”);

The

File class has several static fields that are similar to separator, which are system related and should be used as far as possible in programming.

separatorChar

public static final char separatorChar

is the default name separator associated with the system. This field is initialized to the first character that contains the system property file.separator value. On UNIX systems, the value of this field is ‘/’; On Microsoft Windows, it is ‘\’.

separator

public static final String separator

is the system-specific default name separator, which is represented as a string for convenience. This string contains only one character, separatorChar.

pathSeparatorChar

public static final char pathSeparatorChar

is the system-dependent path separator. This field is initialized as the first character that contains the system property path.separator value. This character is used to separate filenames in a given file sequence in the form of a path list. On UNIX systems, this field is ‘:’; On Microsoft Windows, it is ‘; ‘.

pathSeparator

public static final String pathSeparator

is the system-dependent path separator, which is represented as a string for convenience. This string contains only one character, pathSeparatorChar.

☞ warm prompt: to return to my blog index