SSH File Transfer from Mint to RPi works not bidirectional - linux

I am new to Linux and RPi. I want to transfer a file from my Pi to my PC.
With ...
scp hello pi#192.168.1.101:/home/pi
.. I am able to transfer my file "hell" to my Pi.
But when I try to send the file "elle" with ...
scp elle mirco#192.168.1.104:/home/mirco
i get
ssh: connect to host 192.168.1.104 port 22: Connection timed out lost connection
I read the ssh service status from the pi and my Computer:
Pi:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 14:38:18 CEST; 6s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 14004 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 14006 (sshd)
Tasks: 1 (limit: 4915)
Memory: 804.0K
CGroup: /system.slice/ssh.service
└─14006 /usr/sbin/sshd -D
Apr 08 14:38:18 raspberrypi systemd[1]: Starting OpenBSD Secure Shell server...
Apr 08 14:38:18 raspberrypi sshd[14006]: Server listening on 0.0.0.0 port 22.
Apr 08 14:38:18 raspberrypi sshd[14006]: Server listening on :: port 22.
Apr 08 14:38:18 raspberrypi systemd[1]: Started OpenBSD Secure Shell server.
My Computer:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 14:52:26 CEST; 6min ago
Process: 9224 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 9216 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 8934 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 8935 (sshd)
Tasks: 1 (limit: 4578)
CGroup: /system.slice/ssh.service
└─8935 /usr/sbin/sshd -D
Apr 08 14:52:26 ComputerMirco systemd[1]: Stopping OpenBSD Secure Shell server...
Apr 08 14:52:26 ComputerMirco systemd[1]: Stopped OpenBSD Secure Shell server.
Apr 08 14:52:26 ComputerMirco sshd[8935]: Server listening on 0.0.0.0 port 22.
Apr 08 14:52:26 ComputerMirco systemd[1]: Starting OpenBSD Secure Shell server...
Apr 08 14:52:26 ComputerMirco systemd[1]: Started OpenBSD Secure Shell server.
Apr 08 14:58:12 ComputerMirco systemd[1]: Reloading OpenBSD Secure Shell server.
Apr 08 14:58:12 ComputerMirco sshd[8935]: Received SIGHUP; restarting.
Apr 08 14:58:12 ComputerMirco sshd[8935]: Server listening on 0.0.0.0 port 22.
Can someone help me?
Thank you!
Mirco

Am I correct in thinking you're running the second SCP command on your Pi? If so, your Pi isn't authorized to connect to your PC. You can add it's public key to your authorized_keys file and your Pi will be able to connect to your PC.
You could also pull the file in from your Pi. This is safer because you don't really want your Pi to be able to connect to your PC.
SCP copy to host example
scp pi#192.168.1.101:/home/pi/elle /home/mirco

My guess is that your PC doesn't have ssh enabled.
Install openssh-server on your PC using
sudo apt install openssh-server
After installing this, a system service called ssh should have become active.
You can test this using
sudo systemctl status ssh
Your output should look something like this
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 10:05:07 IST; 13h ago
If it doesn't show active(running), try executing
sudo systemctl enable ssh
If you still are not able to ssh, enable the ssh port through your firewall.
In Ubuntu this can be done by
sudo ufw allow ssh

Related

sshd service fails to start : ssh.service failed because the control process exited with error code

I'm not sure why it isn't starting or why its preventing me from connecting, i get this error:
root#vmi: "# sudo service ssh status
ssh.service OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-11-27 09:47:47 CST; 4min 58s ago
Docs: man: sshd (8) man: sshd_config(5)
Process: 446 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255/EXCEPTION)
Nov 27 09:47:47 vmi.contaboserver.net systemd[1]: ssh.service: Scheduled restart job, restart>
Nov 27 09:47:47 vmi.contaboserver.net systemd[1]: Stopped OpenBSD Secure Shell server.
Nov 27 09:47:47 vmi.contaboserver.net systemd[1]: ssh.service: Start request repeated too qui>
Nov 27 09:47:47 vmi.contaboserver.net systemd[1]: ssh.service: Failed with result 'exit-code'.
Nov 27 09:47:47 vmi.contaboserver.net systemd[1]: Failed to start OpenBSD Secure Shell server. lines 1-12/12 (END)
Please provide more precise log information, just restart sshd service then use journalctl -xe or vim /var/log/secure (if The storage location of the sshd logs has not been changed)

Request timeout when pinging aws Linux instance

So i m trying to install a jenkins server on the free instance provided by aws, so I can test things out, problem is that I can connect via ssh using putty to the public ip and my key, but when I try to access the jenkins portal using the public DNS address and the port a timeout is returned
Also if i try to ping the machine from my laptop it returns "Request time out" every time.
Also jenkins server seems to be running and active:
[ec2-user#ip-1235 ~]$ sudo systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: active (running) since Mon 2021-11-22 16:14:42 UTC; 7min ago
Docs: man:systemd-sysv-generator(8)
Process: 3693 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/jenkins.service
└─3697 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_H...
Nov 22 16:14:42 ip-1234.us-east-2.compute.internal systemd[1]: Start...
Nov 22 16:14:42 ip-1234.us-east-2.compute.internal jenkins[3693]: St...
Nov 22 16:14:42 ip-1234.us-east-2.compute.internal systemd[1]: Start...
Hint: Some lines were ellipsized, use -l to show in full.

ssh service is not getting started after upgrading debian 8 jessie to debian 9 strech

ssh service is not getting started after upgrading debian 8 jessie to debian 9 strech
● ssh.service - OpenBSD Secure Shell server Loaded: loaded
(/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2021-05-28 13:36:30 UTC;
10min ago Process: 2155 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
(code=exited, status=255) Process: 2152 ExecStartPre=/usr/sbin/sshd
-t (code=exited, status=0/SUCCESS) Main PID: 2155 (code=exited, status=255)
May 28 13:36:29 ip-172-31-43-40 systemd[1]: Starting OpenBSD Secure
Shell server... May 28 13:36:30 ip-172-31-43-40 systemd[1]:
ssh.service: Main process exited, code=exited, status=255/n/a May 28
13:36:30 ip-172-31-43-40 systemd[1]: Failed to start OpenBSD Secure
Shell server. May 28 13:36:30 ip-172-31-43-40 systemd[1]: ssh.service:
Unit entered failed state. May 28 13:36:30 ip-172-31-43-40 systemd[1]:
ssh.service: Failed with result 'exit-code'.
kindly check the source list, in your source list might be something that disables the SSH
kindly use the different source list
Kindly change your /etc/apt/source.list to this Link it might work.

python subprocess module gives command not found error if order of command is differerent

I have this code in which i'm using subprocess module to do ssh and run some commands and get the response.
command = "ssh -n " +str(server_name) + " sudo /etc/init.d/postfix status && sudo /etc/init.d/ssh status && sudo /etc/init.d/lldpd status"
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
response, err = result.communicate()
print response
it returns
sudo: /etc/init.d/lldpd: command not found
but if i format command like this
sudo /etc/init.d/lldpd status && sudo /etc/init.d/postfix status && sudo /etc/init.d/ssh status
it works perfectly.it won't work if i put lldpd into other than first position in command.
i can run the command on server in any order and it's working.
Edit:-
for this command
sudo /etc/init.d/postfix status && sudo /etc/init.d/ssh status && sudo /etc/init.d/lldpd status
i have this output
sudo: /etc/init.d/lldpd: command not found
postfix is running.
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: active (running) since Sun 2017-05-28 14:13:49 IST; 19h ago
Process: 20365 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 651 (sshd)
CGroup: /system.slice/ssh.service
└─651 /usr/sbin/sshd -D
May 29 09:36:33 rohit systemd[1]: Reloading OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Received SIGHUP; restarting.
May 29 09:36:33 rohit systemd[1]: Reloaded OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Server listening on 0.0.0.0 port 22.
May 29 09:36:33 rohit sshd[651]: Server listening on :: port 22.
May 29 09:36:33 rohit systemd[1]: Reloading OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Received SIGHUP; restarting.
May 29 09:36:33 rohit systemd[1]: Reloaded OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Server listening on 0.0.0.0 port 22.
May 29 09:36:33 rohit sshd[651]: Server listening on :: port 22.
for this command
sudo /etc/init.d/lldpd status && sudo /etc/init.d/postfix status && sudo /etc/init.d/ssh status
i have this output
lldpd is running.
● postfix.service - LSB: Postfix Mail Transport Agent
Loaded: loaded (/etc/init.d/postfix)
Drop-In: /run/systemd/generator/postfix.service.d
└─50-postfix-$mail-transport-agent.conf
Active: active (running) since Sun 2017-05-28 14:14:10 IST; 19h ago
Process: 20381 ExecReload=/etc/init.d/postfix reload (code=exited, status=0/SUCCESS)
Process: 1350 ExecStart=/etc/init.d/postfix start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/postfix.service
├─ 1474 /usr/lib/postfix/master
├─20395 pickup -l -t unix -u -c
└─20396 qmgr -l -t unix -u
May 29 08:33:43 rohit systemd[1]: Reloaded LSB: Postfix Mail Transport Agent.
May 29 08:33:43 rohit postfix[18121]: Reloading Postfix configuration...done.
May 29 09:36:33 rohit systemd[1]: Reloading LSB: Postfix Mail Transport Agent.
May 29 09:36:33 rohit postfix/master[1474]: reload -- version 2.11.3, configuration /etc/postfix
May 29 09:36:33 rohit postfix[20292]: Reloading Postfix configuration...done.
May 29 09:36:33 rohit systemd[1]: Reloaded LSB: Postfix Mail Transport Agent.
May 29 09:36:33 rohit systemd[1]: Reloading LSB: Postfix Mail Transport Agent.
May 29 09:36:33 rohit postfix/master[1474]: reload -- version 2.11.3, configuration /etc/postfix
May 29 09:36:33 rohit postfix[20381]: Reloading Postfix configuration...done.
May 29 09:36:33 rohit systemd[1]: Reloaded LSB: Postfix Mail Transport Agent.
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: active (running) since Sun 2017-05-28 14:13:49 IST; 19h ago
Process: 20365 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 651 (sshd)
CGroup: /system.slice/ssh.service
└─651 /usr/sbin/sshd -D
May 29 09:36:33 rohit systemd[1]: Reloading OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Received SIGHUP; restarting.
May 29 09:36:33 rohit systemd[1]: Reloaded OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Server listening on 0.0.0.0 port 22.
May 29 09:36:33 rohit sshd[651]: Server listening on :: port 22.
May 29 09:36:33 rohit systemd[1]: Reloading OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Received SIGHUP; restarting.
May 29 09:36:33 rohit systemd[1]: Reloaded OpenBSD Secure Shell server.
May 29 09:36:33 rohit sshd[651]: Server listening on 0.0.0.0 port 22.
May 29 09:36:33 rohit sshd[651]: Server listening on :: port 22.

Unable to activate sendmail due to error

I installed sendmail on my Fedora 21 Server installation but when I start it and check it's status I get the following:
[root#localhost mail]# systemctl status sendmail
● sendmail.service - Sendmail Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/sendmail.service; enabled)
Active: failed (Result: resources) since Thu 2015-06-04 11:23:31 CEST; 2min 39s ago
Process: 31776 ExecStart=/usr/sbin/sendmail -bd $SENDMAIL_OPTS $SENDMAIL_OPTARG (code=exited, status=0/SUCCESS)
Process: 31766 ExecStartPre=/etc/mail/make aliases (code=exited, status=0/SUCCESS)
Process: 31763 ExecStartPre=/etc/mail/make (code=exited, status=0/SUCCESS)
Jun 04 11:23:31 localhost.localdomain sendmail[31776]: -bd is not supported by sSMTP
Jun 04 11:23:31 localhost.localdomain systemd[1]: Failed to start Sendmail Mail Transport Agent.
Jun 04 11:23:31 localhost.localdomain systemd[1]: Unit sendmail.service entered failed state.
Jun 04 11:23:31 localhost.localdomain systemd[1]: sendmail.service failed.
What is the problem here? I thought the -bd is not supported by sSMTP was a hint. But I can't find anything on this either.
sSMTP is a send-only sendmail emulator. It does not support -bd option when run as a daemon (see "man ssmtp"). Current sendmail in F21 is an alias to ssmtp. You need to remove ssmtp entirely from F21 (yum erase sSMTP).

Resources