Tag Archives: Network

Centos8 Could not restart the Network: Failed to restart network.service: Unit network.service not found

Error:

[root@centos8 ~]# service network  status
Redirecting to /bin/systemctl status network.service
Unit network.service could not be found.

[root@centos8 ~]# systemctl status network.service
Unit network.service could not be found.

[root@centos8 ~]# systemctl status network
Unit network.service could not be found.

[root@centos8 ~]# systemctl restart network
Failed to restart network.service: Unit network.service not found.

After installing Centos8, configure the static IP address. If you want to restart the network, the previous commands on Centos7 are hard to use

Error reported as above

After checking the data, it is found that the original network has been replaced by Centos8. The new version is called NetworkManager

This tool is amazing and easy to use. especially those related to wifi,

So you can restart with this command: systemctl restart NetworkManager

[root@centos8 ~]# systemctl status  NetworkManager
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-10-15 22:20:43 CST; 9min ago
     Docs: man:NetworkManager(8)
 Main PID: 7299 (NetworkManager)
    Tasks: 3 (limit: 11357)
   Memory: 6.8M
   CGroup: /system.slice/NetworkManager.service
           └─7299 /usr/sbin/NetworkManager --no-daemon

 

python minio client Error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certific

Built minio service, support https, python call reported error.

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xx.xx.xx.xxx', port=9000): Max retries exceeded with url: /allstruct?location= (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1108)')))

Ignore the certificate error issue and try out the demo script


import os
from minio import Minio
import urllib3
from urllib.parse import urlparse
import certifi
from minio.commonconfig import REPLACE, CopySource
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


minio_endpoint = os.getenv("MINIO_ENDPOINT", "https://xxx.xxx.xxx.xxx:9000")
secure = True

minio_endpoint = urlparse(minio_endpoint)


if minio_endpoint.scheme == 'https':
    secure = True

ok_http_client=urllib3.PoolManager(
            timeout=urllib3.util.Timeout(connect=10, read=10),
            maxsize=10,
            cert_reqs='CERT_NONE',
            ca_certs= os.environ.get('SSL_CERT_FILE') or certifi.where(),
            retries=urllib3.Retry(
                total=5,
                backoff_factor=0.2,
                status_forcelist=[500, 502, 503, 504]
            )
        )


minioClient = Minio(minio_endpoint.netloc,
                    access_key='username',
                    secret_key='password',
                    http_client=ok_http_client,
                    secure=secure)

print(minioClient.list_buckets())

[Solved] Python Error: socket.error [Errno 9] Bad file descriptor

To learn Python Network programming, I wrote two small programs on the server and the client according to the book, and found that an error was reported:

Traceback (most recent call last):

File “./tsTserv.py”, line 20, in

data = tcpCliSock.recv(BUFSIZ)

File “/usr/lib/python2.6/socket.py”, line 165, in _dummy

raise error(EBADF, ‘Bad file descriptor’)

socket.error: [Errno 9] Bad file descriptor

The source code of the server side is as follows:

while True:
        print 'waiting for connection...'
        tcpCliSock,addr = tcpSerSock.accept()
        print '...connected from:',addr
        while True:
                data = tcpCliSock.recv(BUFSIZ)
                if not data:
                        break
                tcpCliSock.send('[%s] %s' %(ctime(),data))
        tcpCliSock.close()
tcpSerSock.close()

Solution:

tcpCliSock.close() is placed in the second while loop, causing tcpCliSock to be closed after receiving data once, and this statement should be placed in the outer loop

[Solved] Using summary to View network parameters Error: RuntimeError: Input type (torch.cuda.FloatTensor)

Use summary to view network parameters

If you need to view the specific parameters of the network, use the use summary

from torchsummary import summary
summary(model, (3, 448, 448))

Show results

        Layer (type)               Output Shape         Param #
================================================================
            Conv2d-1         [-1, 64, 224, 224]           9,408
       BatchNorm2d-2         [-1, 64, 224, 224]             128
              ReLU-3         [-1, 64, 224, 224]               0
         MaxPool2d-4         [-1, 64, 112, 112]               0
            Conv2d-5         [-1, 64, 112, 112]           4,096
       BatchNorm2d-6         [-1, 64, 112, 112]             128
              ReLU-7         [-1, 64, 112, 112]               0
            Conv2d-8         [-1, 64, 112, 112]          36,864
       BatchNorm2d-9         [-1, 64, 112, 112]             128
             ReLU-10         [-1, 64, 112, 112]               0
           Conv2d-11        [-1, 256, 112, 112]          16,384
      BatchNorm2d-12        [-1, 256, 112, 112]             512
           Conv2d-13        [-1, 256, 112, 112]          16,384
      BatchNorm2d-14        [-1, 256, 112, 112]             512
             ReLU-15        [-1, 256, 112, 112]               0
       Bottleneck-16        [-1, 256, 112, 112]               0
           Conv2d-17         [-1, 64, 112, 112]          16,384
      BatchNorm2d-18         [-1, 64, 112, 112]             128
             ReLU-19         [-1, 64, 112, 112]               0
           Conv2d-20         [-1, 64, 112, 112]          36,864
      BatchNorm2d-21         [-1, 64, 112, 112]             128
             ReLU-22         [-1, 64, 112, 112]               0
           Conv2d-23        [-1, 256, 112, 112]          16,384
      BatchNorm2d-24        [-1, 256, 112, 112]             512
             ReLU-25        [-1, 256, 112, 112]               0
       Bottleneck-26        [-1, 256, 112, 112]               0
           Conv2d-27         [-1, 64, 112, 112]          16,384
      BatchNorm2d-28         [-1, 64, 112, 112]             128
             ReLU-29         [-1, 64, 112, 112]               0
           Conv2d-30         [-1, 64, 112, 112]          36,864
      BatchNorm2d-31         [-1, 64, 112, 112]             128
             ReLU-32         [-1, 64, 112, 112]               0
           Conv2d-33        [-1, 256, 112, 112]          16,384
      BatchNorm2d-34        [-1, 256, 112, 112]             512
             ReLU-35        [-1, 256, 112, 112]               0
       Bottleneck-36        [-1, 256, 112, 112]               0
           Conv2d-37        [-1, 128, 112, 112]          32,768
      BatchNorm2d-38        [-1, 128, 112, 112]             256
             ReLU-39        [-1, 128, 112, 112]               0
           Conv2d-40          [-1, 128, 56, 56]         147,456
      BatchNorm2d-41          [-1, 128, 56, 56]             256
             ReLU-42          [-1, 128, 56, 56]               0
           Conv2d-43          [-1, 512, 56, 56]          65,536
      BatchNorm2d-44          [-1, 512, 56, 56]           1,024
           Conv2d-45          [-1, 512, 56, 56]         131,072
      BatchNorm2d-46          [-1, 512, 56, 56]           1,024
             ReLU-47          [-1, 512, 56, 56]               0
       Bottleneck-48          [-1, 512, 56, 56]               0
           Conv2d-49          [-1, 128, 56, 56]          65,536
      BatchNorm2d-50          [-1, 128, 56, 56]             256
             ReLU-51          [-1, 128, 56, 56]               0
           Conv2d-52          [-1, 128, 56, 56]         147,456
      BatchNorm2d-53          [-1, 128, 56, 56]             256
             ReLU-54          [-1, 128, 56, 56]               0
           Conv2d-55          [-1, 512, 56, 56]          65,536
      BatchNorm2d-56          [-1, 512, 56, 56]           1,024
             ReLU-57          [-1, 512, 56, 56]               0
       Bottleneck-58          [-1, 512, 56, 56]               0
           Conv2d-59          [-1, 128, 56, 56]          65,536
      BatchNorm2d-60          [-1, 128, 56, 56]             256
             ReLU-61          [-1, 128, 56, 56]               0
           Conv2d-62          [-1, 128, 56, 56]         147,456
      BatchNorm2d-63          [-1, 128, 56, 56]             256
             ReLU-64          [-1, 128, 56, 56]               0
           Conv2d-65          [-1, 512, 56, 56]          65,536
      BatchNorm2d-66          [-1, 512, 56, 56]           1,024
             ReLU-67          [-1, 512, 56, 56]               0
       Bottleneck-68          [-1, 512, 56, 56]               0
           Conv2d-69          [-1, 128, 56, 56]          65,536
      BatchNorm2d-70          [-1, 128, 56, 56]             256
             ReLU-71          [-1, 128, 56, 56]               0
           Conv2d-72          [-1, 128, 56, 56]         147,456
      BatchNorm2d-73          [-1, 128, 56, 56]             256
             ReLU-74          [-1, 128, 56, 56]               0
           Conv2d-75          [-1, 512, 56, 56]          65,536
      BatchNorm2d-76          [-1, 512, 56, 56]           1,024
             ReLU-77          [-1, 512, 56, 56]               0
       Bottleneck-78          [-1, 512, 56, 56]               0
           Conv2d-79          [-1, 256, 56, 56]         131,072
      BatchNorm2d-80          [-1, 256, 56, 56]             512
             ReLU-81          [-1, 256, 56, 56]               0
           Conv2d-82          [-1, 256, 28, 28]         589,824
      BatchNorm2d-83          [-1, 256, 28, 28]             512
             ReLU-84          [-1, 256, 28, 28]               0
           Conv2d-85         [-1, 1024, 28, 28]         262,144
      BatchNorm2d-86         [-1, 1024, 28, 28]           2,048
           Conv2d-87         [-1, 1024, 28, 28]         524,288
      BatchNorm2d-88         [-1, 1024, 28, 28]           2,048
             ReLU-89         [-1, 1024, 28, 28]               0
       Bottleneck-90         [-1, 1024, 28, 28]               0
           Conv2d-91          [-1, 256, 28, 28]         262,144
      BatchNorm2d-92          [-1, 256, 28, 28]             512
             ReLU-93          [-1, 256, 28, 28]               0
           Conv2d-94          [-1, 256, 28, 28]         589,824
      BatchNorm2d-95          [-1, 256, 28, 28]             512
             ReLU-96          [-1, 256, 28, 28]               0
           Conv2d-97         [-1, 1024, 28, 28]         262,144
      BatchNorm2d-98         [-1, 1024, 28, 28]           2,048
             ReLU-99         [-1, 1024, 28, 28]               0
      Bottleneck-100         [-1, 1024, 28, 28]               0
          Conv2d-101          [-1, 256, 28, 28]         262,144
     BatchNorm2d-102          [-1, 256, 28, 28]             512
            ReLU-103          [-1, 256, 28, 28]               0
          Conv2d-104          [-1, 256, 28, 28]         589,824
     BatchNorm2d-105          [-1, 256, 28, 28]             512
            ReLU-106          [-1, 256, 28, 28]               0
          Conv2d-107         [-1, 1024, 28, 28]         262,144
     BatchNorm2d-108         [-1, 1024, 28, 28]           2,048
            ReLU-109         [-1, 1024, 28, 28]               0
      Bottleneck-110         [-1, 1024, 28, 28]               0
          Conv2d-111          [-1, 256, 28, 28]         262,144
     BatchNorm2d-112          [-1, 256, 28, 28]             512
            ReLU-113          [-1, 256, 28, 28]               0
          Conv2d-114          [-1, 256, 28, 28]         589,824
     BatchNorm2d-115          [-1, 256, 28, 28]             512
            ReLU-116          [-1, 256, 28, 28]               0
          Conv2d-117         [-1, 1024, 28, 28]         262,144
     BatchNorm2d-118         [-1, 1024, 28, 28]           2,048
            ReLU-119         [-1, 1024, 28, 28]               0
      Bottleneck-120         [-1, 1024, 28, 28]               0
          Conv2d-121          [-1, 256, 28, 28]         262,144
     BatchNorm2d-122          [-1, 256, 28, 28]             512
            ReLU-123          [-1, 256, 28, 28]               0
          Conv2d-124          [-1, 256, 28, 28]         589,824
     BatchNorm2d-125          [-1, 256, 28, 28]             512
            ReLU-126          [-1, 256, 28, 28]               0
          Conv2d-127         [-1, 1024, 28, 28]         262,144
     BatchNorm2d-128         [-1, 1024, 28, 28]           2,048
            ReLU-129         [-1, 1024, 28, 28]               0
      Bottleneck-130         [-1, 1024, 28, 28]               0
          Conv2d-131          [-1, 256, 28, 28]         262,144
     BatchNorm2d-132          [-1, 256, 28, 28]             512
            ReLU-133          [-1, 256, 28, 28]               0
          Conv2d-134          [-1, 256, 28, 28]         589,824
     BatchNorm2d-135          [-1, 256, 28, 28]             512
            ReLU-136          [-1, 256, 28, 28]               0
          Conv2d-137         [-1, 1024, 28, 28]         262,144
     BatchNorm2d-138         [-1, 1024, 28, 28]           2,048
            ReLU-139         [-1, 1024, 28, 28]               0
      Bottleneck-140         [-1, 1024, 28, 28]               0
          Conv2d-141          [-1, 512, 28, 28]         524,288
     BatchNorm2d-142          [-1, 512, 28, 28]           1,024
            ReLU-143          [-1, 512, 28, 28]               0
          Conv2d-144          [-1, 512, 14, 14]       2,359,296
     BatchNorm2d-145          [-1, 512, 14, 14]           1,024
            ReLU-146          [-1, 512, 14, 14]               0
          Conv2d-147         [-1, 2048, 14, 14]       1,048,576
     BatchNorm2d-148         [-1, 2048, 14, 14]           4,096
          Conv2d-149         [-1, 2048, 14, 14]       2,097,152
     BatchNorm2d-150         [-1, 2048, 14, 14]           4,096
            ReLU-151         [-1, 2048, 14, 14]               0
      Bottleneck-152         [-1, 2048, 14, 14]               0
          Conv2d-153          [-1, 512, 14, 14]       1,048,576
     BatchNorm2d-154          [-1, 512, 14, 14]           1,024
            ReLU-155          [-1, 512, 14, 14]               0
          Conv2d-156          [-1, 512, 14, 14]       2,359,296
     BatchNorm2d-157          [-1, 512, 14, 14]           1,024
            ReLU-158          [-1, 512, 14, 14]               0
          Conv2d-159         [-1, 2048, 14, 14]       1,048,576
     BatchNorm2d-160         [-1, 2048, 14, 14]           4,096
            ReLU-161         [-1, 2048, 14, 14]               0
      Bottleneck-162         [-1, 2048, 14, 14]               0
          Conv2d-163          [-1, 512, 14, 14]       1,048,576
     BatchNorm2d-164          [-1, 512, 14, 14]           1,024
            ReLU-165          [-1, 512, 14, 14]               0
          Conv2d-166          [-1, 512, 14, 14]       2,359,296
     BatchNorm2d-167          [-1, 512, 14, 14]           1,024
            ReLU-168          [-1, 512, 14, 14]               0
          Conv2d-169         [-1, 2048, 14, 14]       1,048,576
     BatchNorm2d-170         [-1, 2048, 14, 14]           4,096
            ReLU-171         [-1, 2048, 14, 14]               0
      Bottleneck-172         [-1, 2048, 14, 14]               0
          Conv2d-173          [-1, 256, 14, 14]         524,288
     BatchNorm2d-174          [-1, 256, 14, 14]             512
          Conv2d-175          [-1, 256, 14, 14]         589,824
     BatchNorm2d-176          [-1, 256, 14, 14]             512
          Conv2d-177          [-1, 256, 14, 14]          65,536
     BatchNorm2d-178          [-1, 256, 14, 14]             512
          Conv2d-179          [-1, 256, 14, 14]         524,288
     BatchNorm2d-180          [-1, 256, 14, 14]             512
detnet_bottleneck-181          [-1, 256, 14, 14]               0
          Conv2d-182          [-1, 256, 14, 14]          65,536
     BatchNorm2d-183          [-1, 256, 14, 14]             512
          Conv2d-184          [-1, 256, 14, 14]         589,824
     BatchNorm2d-185          [-1, 256, 14, 14]             512
     BatchNorm2d-197           [-1, 30, 14, 14]              60
================================================================

Error reported:

RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

Run the model in the graphics card:

from torchsummary import summary
summary(net.cuda(), (3, 448, 448))

[FAILED] Failed to start Raise network interfaces

[FAILED] Failed to start Raise network interfaces. 

The following error occurred during startup. Linux and windows cannot communicate. The reason may be that DHCP and static IP conflict. Use the ifconfig command to check that there is only IPv6 address but no IPv4 address.

 

Solution:

Modify the following file: /etc/network/interfaces.d/eth0, remove static IP settings or DHCP settings:
for example:

remove DHCP and replace it with:

auto eth0
iface eth0 inet static
address 192.168.2.99
netmask 255.255.255.0

Restart and the problem is solved.

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) This is because port 80 can only be started by the root user, so just let the non-root user use port 80.

The solution is as follows:

# Set CAP_NET_BIND_SERVICE capability for the specified program
$ setcap cap_net_bind_service=+eip /path/to/application
The tests are as follows:
# sudo setcap cap_net_bind_service=+eip /usr/local/nginx/sbin/nginx

It’s OK to start nginx again.

/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf

[Solved] ffmpeg Enable https Error: “ERROR: openssl not found”

ffmpeg can use libssl.so libcrypto.so dynamic library, or libssl.a libcrypto.a static library, the next is to say that obviously the inventory is there, but the compiler still can not find openssl.

Search the ffmpeg source code, and you can find that the prompt is printed in the configure file. The source code is as follows:

enabled openssl           && { use_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl ||
                               check_lib openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto ||
                               use_pkg_config openssl openssl/ssl.h SSL_library_init ||
                               check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
                               check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
                               check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
                               die "ERROR: openssl not found"; }

You can find that ffmpeg is trying OpenSSL one by one. My config The log shows that the last one has been checked, but OpenSSL is still not found.

The reason is that I am using a newer openssl library, the old openssl library uses ‘SSL_library_init’ to initialize, the newer openssl version uses ‘OPENSSL_init_ssl’ to initialize. The new version of openssl uses ‘OPENSSL_init_ssl’ to initialize, and because it does not pass the check, this error is reported here.

Solution:

Add a line to check ‘check_lib openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto ‘ and it will pass, above is what I have added.

 

[Solved] Linux C++ Compile Error: c++: internal compiler error: Killed (program cc1plus)

Compilation error:

/home/service/rpc/goya-rpc/src/rpc_server_impl.cc: In member function ‘void goya::rpc::RpcServerImpl::OnCallbackDone(google::protobuf::Message*, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >)’:
/home/service/rpc/goya-rpc/src/rpc_server_impl.cc:101:44: warning: ‘int google::protobuf::MessageLite::ByteSize() const’ is deprecated (declared at /home/service/rpc/goya-rpc/thirdparty/install/include/google/protobuf/message_lite.h:430): Please use ByteSizeLong() instead [-Wdeprecated-declarations]
   int serialized_size = resp_msg->ByteSize();
                                            ^
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [src/CMakeFiles/goya-rpc.dir/rpc_server_impl.cc.o] Error 4
make[1]: *** [src/CMakeFiles/goya-rpc.dir/all] Error 2
make: *** [all] Error 2

The reason for the error is that the compiling machine is running out of memory, and a large number of template extensions need enough memory.

#View linux memory usage by.
1.ps aux --sort -rss
2.free -m
3.top  Press [shift + M keys] to arrange them in reverse order
4.cat /proc/meminfo

Solution:

You can solve this problem by temporarily using swap partitions:

=[step 1: operate as follows]=========================================

Sudo DD if=/dev/zero of=/swapfile bs=64m count=16
\count is the size of the increased swap space. 64M is the block size, so the space size is bs*count=1024mb
sudo mkswap /swapfile \

=[step 2: close release] ==================================================================================

Sudo swapoff /swapfile
sudo RM /swapfile
then continue to perform your relevant operations…

Note: if you still prompt “g++: internal compiler error: killed (program cc1plus)” after creating the temporary space, it may be because the allocated space is not large enough. You can continue to allocate more space.

[Solved] OpenSSL Error messages: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

In these two days, the service has been reporting when calling Baidu’s addressing and positioning interface and reverse address resolution:

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

The query results of the interface are affected, and finally the curl call problem is solved:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 4);
$reponse = curl_exec($ch);

CURLOPT_SSLVERSION Fetch value and meaning
CURL_SSLVERSION_TLSv1_2 requires php version >= 5.5.19
TLS 1.1 and TLS 1.2 are supported since OpenSSL 1.0.1

CURL_SSLVERSION_DEFAULT (0)
CURL_SSLVERSION_TLSv1 (1),
CURL_SSLVERSION_SSLv2 (2), 
CURL_SSLVERSION_SSLv3 (3),
CURL_SSLVERSION_TLSv1_0 (4),
CURL_SSLVERSION_TLSv1_1 (5),
CURL_SSLVERSION_TLSv1_2 (6).

[Solved] “status“:405,“error“ Request method ‘POST‘ not supported“

“status“:405,“error“ Request method ‘POST‘ not supported“

Error Messages:

-“status”:405,“error”:“Method Not Allowed”,“exception”:“org.springframework.web.HttpRequestMethodNotSupportedException”,“message”:“Request method ‘POST’ not supported”

 

code:

@Controller
public class EmpController {

    @Autowired
    private EmpService empService;

    @GetMapping("/empadd")
    public String empAdd(Model model) {
        model.addAttribute("list",empService.showAll());
        return "emp-add";
    }

    @PostMapping("/add")
    public String add(Emp emp, MultipartFile file){
        empService.insert(emp,file);
        return "emp-add";
    }
}

 

Reason:
As it says in the Spring REST guide,

@RequestMapping maps all HTTP operations by default

but if, as they suggest, you added a specification of the allowable http methods:

@RequestMapping(method=GET)

then only GETs will be allowed. POSTs will be disallowed.
If you want to allow both GET and POST, but disallow all other http methods, then annotate your controller method thusly:

@RequestMapping(value = "/greeting", method = {RequestMethod.GET, RequestMethod.POST})
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
    return new Greeting(counter.incrementAndGet(),
                        String.format(template, name));
}

When you start the application, all the request handler mappings are logged out. You should see a line like this in your log (in the IDE console or command line window):

s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting],methods=[GET || POST]}" onto public hello.Greeting hello.GreetingController.greeting(java.lang.String)

Solution:

Modify

@GetMapping("/empadd")

to

@RequestMapping("/empadd")

[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]$