Tag Archives: ssh

Solution to the problem of multiple parameters when using pipeline under Linux

When doing the project today, we encountered a problem, that is, how to use the pipeline under the Linux command. We will certainly use the simple pipeline, just like this form

<span style="font-size:18px;">ls -a | grep *test</span>

Today’s problem is a bit complicated. It is to scan the system log in real time, from the last line after scanning to the end of the file, and match keywords. If they match, an alarm will be given. I use awk with grep command to achieve

Awk command is used to select log segment output as the input of grep command

awk 'NR>= beginLineNum&& NR<endLineNum logFileName  | grep -nE  pattern ;

But how to get the total row number of the current log becomes a problem. The command to get the total row number is

wc -l logFileName

But the result after WC is to be placed in the position of Ender linenum, which can not be realized by | method. After query, it is found that it can be realized by using the ‘` symbol (` symbol is the key under the ESC key on the keyboard)

So the way to do it is

awk 'NR>= beginLineNum&& NR<`wc -l logfileName` logFileName  | grep -nE  pattern ;

When executing commands in Linux, the commands in ‘will be executed first, and then other commands will be executed

“As standard input, the return value of the command inside is input into the command outside.

The solution of Hibernate query returning all null lists

Today, when I was working on a project, I used HQL to look up the database, but all the returned results were null. Note that the returned list is not null, but there are values in the list. The size of the list is the total number of records, but when I traverse the list output, all the elements in the list are null. I suspect that there is something wrong with my conditions. I have removed all the conditions, leaving only one sentence:

String hql = "from CarMaintain t";

It’s worth the rest of the sentence, but it’s still the result. I searched the information on the Internet, and all of them were wrong answers. Without exception, I said it was impossible… Then how did I meet… Others are unreliable, so we have to find our own problems.

I began to analyze, why only this sentence has this situation, and other sentences are OK?I found that the table in question has no primary key. Yes, that’s the reason. When there is no primary key, hibernate’s reverse engineering will automatically construct a composite primary key for us, so I started to check hbm.xml The file and configuration are correct. What’s the problem?I collapsed all afternoon for it. The reason is due to the internal mechanism of hibernate,

In my table without primary key, the fields in the composite primary key constructed by hibernate have null values, so no matter how you look it up, it is null in the end. When you break the point, you will see [null, null, null,….]

resolvent:

1. Create a new field, use it as the primary key, and hbm.xml The file is modified correctly

2. All fields contained in the composite primary key cannot be null in the database

It took a long time to solve this problem. I hope I can help you.

Float: 99: input / output error appears in vscode SSH plug-in

Flock: 99: Input/ Output error in VSCode SSH plugin

The SSH plugin for VSCode will get lock under ~/.vscode-server by default, but on some servers mounted on NFS the flock: 99: Input/output error
Solution is to acquire the lock, under/TMP In SSH plugin Settings selected LockFiles In Temp, or search remote. SSH. LockfilesInTmp can find this setting.
Reference: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference

About Using SSH connection for Linux server

About using SSH to connect to the LIUNX server

Step 1

Generate the key on the server side

ssh-keygen -t rsa
Step 2

Add the public key to the server authorization file

id_rsa.pub >> authorized_keys
Step 3
cat id_rsa

Copy the private key to window, create a new text document and paste it. Use putty-gen to generate the private key *.ppk for putty

Step 4

Connection -> when using PuTTY Connection; SSH -> Auth Click Browse to select the generated *.ppk and then click Open

putty Network error:Software caused Connection abort solution – measured valid

First of all, I from the Internet Baidu a lot of answers, tried a lot of times are useless, a chance, let me find a real solution in the post.
Not wordy ~

    local computer pull up the command line win+R enter the regedit go to the registry find HKEY_CURRENT_USER find the software HKEY_CURRENT_USER\ software \SimonTatham delete putty in there and download puttyperfect~~~

Can help friends to solve more to see ~~~

Linux configuration SFTP server

Add user group

groupadd sftp

Add users and set to SFTP group

sudo useradd -g sftp -s /sbin/nologin -M sftp

Modify the SFTP user’s password

sudo passwd sftp

***********

Create the root directory of the SFTP user and set the owner and group, modify the permissions (755)

cd /home
sudo mkdir sftp

sudo chown root:sftp sftp

sudo chmod 755 sftp

Create admin writable directory
in the directory of SFTP

cd sftp
sudo mkdir report

sudo chown admin:sftp report/

Modify the configuration file

sudo vim /etc/ssh/sshd_config

Modify the

#Subsystem      sftp    /usr/libexec/openssh/sftp-server
Subsystem       sftp    internal-sftp

Add at the end of the sshd_config file

Match User sftp
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp
        ChrootDirectory /home/sftp

Restart the SSHD service

sudo service sshd restart

ftp client:

address : 192.168.1.10

user: sftp

password: xxxxxxx

protocol type : SSH2

port: 22

server folder: /home/sftp

pls use CuteFTP Pro® 8.3.3 or last version.

because CuteFTP Pro® 8.3.2 or earlier has no AES128 and AES256 ciphers.

will raise throw “SFTP21 error = #4” .

win10 unable to start ssh-agent service, error :1058 solution

Reference [https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/] set up SSH key, use the command SSH - add ~ /. SSH/id_rsa result Error
Error connecting to the agent: Unable to start ssh-agent: ssh-agent, error:
unable to start ssh-agent service, error :1058

win+R opens the service to see if the "OpenSSH Authentication Agent" service is enabled. If it is "disabled", set the service to "Automatic" and then open the service

failed to lazily initialize a collection of role: ……, no session or session was closed

I encountered this error when Writing a book management system using the SSH framework

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.cc.library.domain.Reader.borrowInfos, no session or session was closed
    at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
    at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
    at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
    at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
    at org.hibernate.collection.PersistentSet.toString(PersistentSet.java:332)

    at java.lang.String.valueOf(String.java:2827)
    at java.lang.StringBuilder.append(StringBuilder.java:115)
    at com.cc.library.domain.Reader.toString(Reader.java:157)
    at java.lang.String.valueOf(String.java:2827)
    at java.lang.StringBuilder.append(StringBuilder.java:115)
    at java.util.AbstractCollection.toString(AbstractCollection.java:422)
    at java.lang.String.valueOf(String.java:2827)

    at java.io.PrintStream.println(PrintStream.java:771)
    at org.apache.tomcat.util.log.SystemLogHandler.println(SystemLogHandler.java:269)
    at com.cc.library.dao.impl.ReaderDaoImpl.findReaderByPage(ReaderDaoImpl.java:120)
    at com.cc.library.service.impl.ReaderServiceImpl.findReaderByPage(ReaderServiceImpl.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy15.findReaderByPage(Unknown Source)
    at com.cc.library.action.ReaderManageAction.findReaderByPage(ReaderManageAction.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)

    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2440)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2429)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:619)


After looking up online information:
in WEB level application, there will be an unexpected lazy error, the solution is to set lazy= “false”

ssh port forwarding

Haihan Zhou July 2, 2010

Goddady’s Linux virtual host is used to provide SSH. However, when using SSH-D port XXX @server, I encountered the following error of SSH printing:

channel 3: open failed: administratively prohibited: open failed

When the Firefox browser is configured with SOCKS5 pointing to a local port, browsing any web page appears blank.
What is the reason for this?
SSH, open sSHd_config and have a look.

cat /etc/ssh/sshd_config

There was a row:

AllowTcpForwarding no

The original host set the TCP port forwarding for SSH to be disabled. That wants to use SSH as agent to carry out port forwarding is certainly unsuccessful.
Look at the system configuration again, also prohibit IP forwarding;

cat /etc/sysctl.conf | grep ip_forward
net.ipv4.ip_forward = 0

Therefore, the virtual host prompt port forwarding is prohibited, normal.

Failed to restart ssh.service: Unit not found.

1,

after modifying the sshd_config configuration file

vim /etc/ssh/sshd_config

2. Restart SSH

service ssh restart

3, the following error

Redirecting to /bin/systemctl restart ssh.service
Failed to restart ssh.service: Unit not found.

4, reason: the above command is centos6 inside the command, centos7 need to use

systemctl restart sshd

5, the problem is perfectly solved, nice