Digital Ocean SSH Returns 'shell request failed on channel 0' - ssh

I have been running a few continuous Python script fetching data from APIs and loading in MySQL, for last few days I notice that when I try to ssh it gives the error:
Digital Ocean SSH Returns 'shell request failed on channel 0'
I googled and the only solution I found was to restart the droplet which is horrible especially if running production code. I even was not able to view the console via the web interface of the digital ocean. My Droplet is in Singapore.
Let me add further that the server remains up, the apache is responding and I can view web pages I had created. Only SSH and SFTP stop working.
Can anyone help me?

Related

google colab ssh connection timesout

I am trying to follow the numerous tutorials and gists such as:
https://gist.github.com/creotiv/d091515703672ec0bf1a6271336806f0
https://stackoverflow.com/questions/48459804/how-can-i-ssh-to-google-colaboratory-vm/53252985#53252985
When I run the steps, it seems like everything went fine (I get the root password), but I do see this:
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
but unfortunately, after all the steps when I do the following on my local machine:
ssh -p17057 root#0.tcp.ngrok.io
I get:
ssh: connect to host 0.tcp.ngrok.io port 17057: Connection timed out
I am on vanilla Debian Buster - any pointers to why this is happening would be incredibly useful to debug
thank you.
I also had trouble ssh'ing into the ngrok tcp tunnel. I was using my local laptop as the access point to the colab VM. What I did was fire up an EC2 instance on AWS and use that instead. Also, I used ssh reverse tunnel and dropped the need for ngrok altogether since the ec2 machine already had a public IP. Check my answer here: https://stackoverflow.com/a/63186681/4126114

Google Cloud: Cannot connect to server via SSH

Port is up, firewall disabled, but connection is rejected with message:
"Read from socket failed: Connection reset by peer".
Other services in the same host are responding well.
SSH through Google Cloud Console gets the same error.
Is there any other method for Google Compute Engine to get shell?
Yes, there is a way to get shell, and it is through the serial port, a really useful feature Google Cloud provides.
There, I saw the error was about key file permissions:
Sep 30 10:51:02 localhost sshd: Permissions 0775 for '/etc/ssh/ssh_host_rsa_key' are too open.
And by assigning 0600 perms to this file everything went back to normal.

Unable to connect to instance through SSH in google compute engine , another instance of same account works fine

I am trying to connect to my instance using gcloud compute ssh new-instance .. it's gives the following error:
ssh: connect to host 107.167.180.68 port 22: Connection refused
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
See https://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.
I had already tried all the possible solution mentioned in the google document.
Any suggestions on how to get a backup of the Database and file? The site has been down for the last two days
Thanks in advance
I'd recommend looking at the serial console output of the VM instance using gcloud compute instances get-serial-port-ouput or using "View serial port" button on the instance page in Cloud Console. That output should give you information about what is wrong with the VM, such as whether it runs out of memory or ran out of disk space or something like that. Also, make sure you didn't change the VM's network firewall rules to accidentally disallow incoming traffic on port 22.
The documentation page for SSH from the Browser also has some additional tips on how to explore this kind of issues - see here and here.
You can use the ssh keys with other instances of your account if you update the ssh keys in your metadata by
sudo gcloud compute config-ssh

Google Cloud server (GCE), custom image, SSH login issue

I'm playing with Google Compute Engine(GCE) as I'm planning to migrate the cloud service provider from Rackspace(reason: GCE has good upgrade plans with best discount price).
I have few issues with GCE and one of them is Ubuntu os/image not supported by default. But there is an alternate method to run any linux distro in GCE, which is called Building an image from scratch for uploading custom images and creating instances(servers) from uploaded image.
I could able to create and run the instances from the Ubuntu image I uploaded to GCE following the link hagikuratakeshi.hatenablog.com. This is simply running ubuntu in general. I didn't face any problem but google's gcutil tool prompts for ssh passphrase and adds the key in GCE meta data but accepts only password logins(then why it prompts for passphrase).
I want to strictly follow Building an image from scratch as recommended by google. But after following all the steps, I could not able to login to my server instance via SSH. I guess this happens when I install Google Compute Engine image packages: google-startup-scripts_1.1.2-1_all.deb, google-compute-daemon_1.1.2-1_all.deb & python-gcimagebundle_1.1.2-1_all.deb. These packages/scripts make some changes to the instance at the startup and also to SSH configuration which are Strongly recommended. Once I strictly follow the link or once I install these packages I could not able to establish SSH connection once the instance is rebooted. The error message similar to the one below is shown while trying to connect:
test#machine1:~$ gcutil --service_version="v1" --project="mypro-555" ssh --zone="asia-east1-a" "server-instance-1"
INFO: Running command line: ssh o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /home/test/.ssh/google_compute_engine -A -p 22 test#101.167.xxx.xxx -
ssh: connect to host 101.167.xxx.xxx port 22: Connection refused
NOTE: The user account test is available and common on both local and GCE server!.
My main problem is SSH connection when I strictly follow the steps. If I upload the fresh image and then follow the recommended steps connecting SSH, I could not do SSH again once I restart the instance (or) if I setup everything in the uploaded image before uploading, the created instance will be running but I could not able to connect atleast ones and the error is same.
Anybody using GCE with your custom image?, are you allowed to connected even after following the recommended settings?. Anyone already fixed this SSH issue?. Please post your comments!
EDIT 1
I could not figure out from the logs and here is the output of gcutil getserialportoutput server-instance-1.
The key here is that your ssh client says "connection refused". This indicates that there is indeed a machine at that IP address, but it's not accepting SSH connections. There are a few possible explanations:
The ssh daemon isn't running, or is listening on the wrong interface
Your instance is configured with a firewall that's denying SSH traffic
The GCE firewall rule to allow SSH traffic has been removed

How to check connectivity of apns port 2195 from my hosting server?

I want to check if Push Notification can be done using a hosting server before purchasing hosting plan.what is the shortest way to check this.Also i have godaddy.com's hosting plan can i use push notification from godaddy's hosting server?
You can confirm definitively by using telnet and specifying which port to connect to. From the command line run:
MyServer:~ Home$ telnet gateway.sandbox.push.apple.com 2195
Trying 17.149.34.143...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
If there is an error connecting then it will just hang and not return - the above shows a working example where I can connect.
You'll need an SSH login to your hosting service to test it this way, and unfortunately you are unlikely to be able to test it without buying an account - so you probably have to rely on asking their customer services.
Be aware that basic hosting packages normally just provide an FTP login to let you serve up files, you'll usually have to pay extra to get a hosting package which provides SSH access (which you'll need if you are going to run code to connect to the Apple Push Notification Servers).
if your system does not have telnet, you can make use of curl to do the job.
curl -v telnet://gateway.sandbox.push.apple.com:2195
here -v is for verbose output
Use Curl if telnet command is not available.
curl -v telnet://gateway.sandbox.push.apple.com:2195
* Rebuilt URL to: telnet://gateway.sandbox.push.apple.com:2195/
* Trying 17.188.137.190...
* TCP_NODELAY set
* Connected to gateway.sandbox.push.apple.com (17.188.137.190) port 2195 (#0)
Press Escape to close the connection
* Closing connection 0
I also had this issue with GoDaddy. Amazon Web Services did the trick for me. It allows you to easily deploy a PHP script which can be called anywhere on the web.
I just purchased my Godaddy account to find out it blocks all connections except 80 and one other. In other words we can't use the 2195 connection that is required. If you find another one please let me know.