Python script to connect ssh devices without using Paramiko - python-3.10

I am trying to write a simple script to connect to the router via ssh from the Window. I use subprocess and it seems working but do not know how the script passes the password
paramiko always gives me the error
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\general_name.py", line 16, in
ipaddress.IPv4Address,
AttributeError: module 'ipaddress' has no attribute 'IPv4Address'

Related

connection to selenium webdriver and airflow

so today i was trying to web scrape via apache-airflow but it is giving this error
File "/home/siva/.local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 89, in __init__
self.service.start()
File "/home/siva/.local/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 105, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /d/apache-airflow/dags/chromedriver.exe
what should I do to connect the service so the web scrapping can be done I run my airflow test bench in ubuntu wsl so if there is any solution please provide it to get its work done in airflow
or if there are other ways to scrape in airflow do suggest.
Can not connect to the Service /d/apache-airflow/dags/chromedriver.exe
I don't have this set up to test with Airflow to be sure, but I have successfully run Chrome with Selenium under WSL2.
It sounds like you might be following some old instructions that were applicable for WSL1. Under WSL1, my understanding is that it is possible to use the Windows Chrome executable/webdriver.
You might want to try switching to WSL1, but I don't know for sure that Airflow will run there. It's very likely that it will.
However, if you do need to use WSL2, you'll have to use the Linux binaries.
This means that you'll need to install Google Chrome inside the WSL distribution and use the corresponding chromedriver_linux64.zip.
You'll also need to either ...
... be running WSL with the ability to run graphical applications - If you have Windows 11, this is automatic. If not, I recommend Xrdp as the next easiest path.
... or run Chrome in headless mode. I'm not sure off the top of my head how to do this with Airflow, unfortunately.

VSCode Remote SSH to Linux - Connecting was canceled

I am trying to connect from my Windows 10 machine to my Ubuntu Linux server (16.04.6) using Remote SSH.
To do this I've read many different tutorials but have no success.
I am able to connect from my Windows 10 command prompt to the Ubuntu Linux server via ssh without any problems. I even used ssh-keygen to generate a private and a public key and copied the public key to the appropriate directory on the Linux Server (.ssh).
In VsCode I installed the extension Remote-SSH added my host to my configuration file c:\user.ssh\config:
Host <ip-address>
HostName <ip-address>
User <username>
Then I clicked in VSCode the button bottom left "Open a remote Window" and chosed my host. A new windows opens and VSCode is trying to connect. Then I see a window with the error message: "Could not establish connection to . Connection was canceled". This is the log.
[11:53:17.573] Log Level: 2
[11:53:17.582] remote-ssh#0.51.0
[11:53:17.583] win32 x64
[11:53:17.586] SSH Resolver called for "ssh-remote+<ip-address>", attempt 1
[11:53:17.587] SSH Resolver called for host: <ip-address>
[11:53:17.587] Setting up SSH remote "<ip-address>"
[11:53:17.648] Using commit id "5763d909d5f12fe19f215cbfdd29a91c0fa9208a" and quality "stable" for server
[11:53:17.650] Install and start server if needed
[11:53:18.624] getPlatformForHost was canceled
[11:53:18.625] Resolver error: Connecting was canceled
[11:53:18.640] ------
Again, I can connect to the same linux server via ssh from my local machine (Win 10) without any problems.
I've resolved the connection issues; possibly the ssh config was not correctly saved/accessed by VS Code?
I thought I should be able to directly set it up to point to an existing config file, but that didn't seem to work. Instead, I created a new config file in the UI, and over-wrote the contents. Shouldn't be necessary, but seemed to do the trick.
What I did was:
Add new host: => Remote-SSH: Connect to host... => Add New SSH Host...
Type in command: ssh user#host to attempt to connect
Choose platform in the command bar in the new window (Linux in my case)
Verify connected (I needed to change ssh-agent settings to store credentials)
Edit the config location: => Remote-SSH: Connect to host... => Settings
Enter config file under Remote.SSH: Config File (C:\Users\me\.vagrant\machines\default\virtualbox\config in my case)
Modify config file further, as needed
Connect through the UI: Remote-SSH: Connect to host... =>
Hope that helps!
For me it was not starting necessary SSH*. See status services using:
Get-Service SSH* on PowerShell.
I got a time out error on enabling necessary services and this helped.
A colleague of mine was with this problem. We solved just deleting his %USERPROFILE\.ssh\config file, closing VSCode, reopening it, and trying to connect again.
There was some garbage in his ssh config file.
I also found that if the value of the "Host" field includes a ")" character, then there will be an error message as follows and the VSCode keeps trying opening remote:
The terminal process "C:\WINDOWS\System32\cmd.exe /c (type "C:\Users\xxxxx_xxxxx\AppData\Local\Temp\vscode-linux-multi-line-command--ccton_---_---2-705401992.sh" | ssh -T -L 127.0.0.1:53080:/run/user/1000/vscode-ssh-remote-server-sock-1636523090 Accton_AWS_EC)2 bash) & exit /b 0" terminated with exit code: 1.
I tried the following that worked for me:
Click on View > Command Palette (alternatively press CTRL + Shift + P)
Start typing:
Remote SSH: Kill
Click on the first option that says: Remote-SSH: kill VS Code Server on Host...
From the options, click on the server you are having trouble connecting to. This will kill that VScode server.
Now just try to reconnect:
a. View > Command Palette (alternatively press CTRL + Shift + P)
b. Start typing:
SSH Remote-SSH: Connect to host...
c. Select the server.
Adding my 2 cents here, I too had lots of trouble connecting to a remote using "Remote SSH Extension of Microsoft". Unfortunately, no luck and spent a lot of time trying all ways possible.
I found another extension named "SSH Client" by cweijan. It was easy and I was able to access my remote using it.
When I had this issue it was because the extension was complaining that the pem file permissions were too open, it should be accessible just by my current user.
Yes, I would like to ~ add on top of Shivam Popat's answer.
Configure F1 ssh.add and Option to add client, and password appears.
Now, connect, and save.
From the left pane you would see icon of key. and upon clicking it will open the remote folders.
The previous problem with VScode remote SSH resolved.

when try to run .bat file as background service in windows 10 , given error

I want to run .bat file as windows service. I used following step , but when try to start service given this error.expect some expert help to resolve this.
1) File location
2) Create Service command prompt as Admin
3) Service create , successful and view in Services.
4) when try to start given same error
I try to do it , using this web reference. but it also given same error.
[Ref. link]
My .Bat file content like this
IntelliJIDEALicenseServer_windows_amd64.exe -p 41018 -u a.b
when run .bat console every thing working fine.

vertica install failing with ssh error

I was trying to install vertica using /opt/vertica/sbin/install_vertica script and following command /opt/vertica/sbin/install_vertica -s vertica001,vertica002,vertica003 -r /root/packages/vertica-6.0.1-7.x86_64.RHEL5.rpm
I was getting following error
Vertica Analytic Database 6.0.1-7 Installation Tool
Starting installation tasks...
Getting system information for cluster (this may take a while)....
'failed to login to 172.16.10.212: EOF ERROR: Could not login with SSH. Here is what SSH said: (publickey,gssapi-keyex,gssapi-with-mic).\r\r\n'
Updating Nodes that are UP
'failed to login to 172.16.10.18: EOF ERROR: Could not login with SSH. Here is what SSH said: (publickey,gssapi-keyex,gssapi-with-mic).\r\r\n'
Updating Nodes that are UP
Removing 172.16.10.212,172.16.10.18 from hosts list
backing up admintools.conf on 172.16.10.52
Info: the package 'pstack' is useful during troubleshooting. Vertica recommends this package is installed.
Checking/fixing OS parameters.....
Error: No JSON object could be decoded
Traceback (most recent call last):
File "/opt/vertica/bin/verticaInstall.py", line 1187, in <module>
if not SSH.check_min_free_kbytes(installerSSH, fix=True):
File "/opt/vertica/oss/python/lib/python2.7/site-packages/vertica/network/SSH.py", line 2388, in check_min_free_kbytes
data =json.loads( ''.join(res[host][1]))
File "/opt/vertica/oss/python/lib/python2.7/json/__init__.py", line 310, in loads
return _default_decoder.decode(s)
File "/opt/vertica/oss/python/lib/python2.7/json/decoder.py", line 346, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/vertica/oss/python/lib/python2.7/json/decoder.py", line 364, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
I have setup passwordless ssh for dbadmin also it has sudo access.
Do I need to have passwordless ssh for root user here ? what I am missing here ?
Do I need to have passwordless ssh for root user here ? what I am missing here ?
Yes. The installer runs on the nodes specified in the host parameter. If SSH is not set up between the nodes, how else is the installer supposed to complete the process? See Configuring the Network and how to Enable Secure Shell (SSH) Logins in the doc.
Q: Why are you installing Vertica 6.0? The latest release is 7.2

Google App Engine: Sendmail, command not found

I'm trying to get sendmail working on localhost. The problem is that the app engine has det wrong path to sendmail, since it throws the error: /bin/sh: sendmail: command not found
Using Mac OS X, the path to sendmail is: /usr/sbin/sendmail
Does anyone know how to change this?
..fredrik
I don't know how to change it but a symlink will do the job. I had the same problem and this solved it:
sudo ln -s /usr/sbin/sendmail /usr/bin/sendmail
Another option is to configure your local AppEngine runtime to use an external SMTP server.
According to the documentation,
The web server will use the sendmail
command to send email messages, with
your installation's default
configuration
If it uses NETINFO to determine the location of sendmail, the full path to sendmail.cf is stored as the value of the "sendmail.cf" property in the "/locations/sendmail" subdirectory of NETINFO, so try to set the value of this property to "/usr/sbin/sendmail.cf" (without the quotes)
Hope it helps

Resources