Saturday, January 29, 2011

GPG encrypt and decrypt with ssh-agent

I use ssh regularly and have ssh-agent set up.

How can I use ssh keys to gpg-encrypt a file?

Edit: It seems that this is impossible. Why? ssh can encrypt traffic, so why not also files?

  • No, SSH keys are not PGP keys and serve different purpose .
    You must have PGP keys in GnuPG keyring.
    But - you can convert GPG keys to PGP keys (using gpgkey2ssh) and gpg-agent can take care of ssh keys (using --enable-ssh option). I believe no such tool exists for converting SSH keys to GPG keys and cannot exist.

    nalply : I prefer to work in the reverse: use gpg with ssh keys, since I already have an extensive ssh infrastructure.
    Kristaps : that is not possible. Just view size of SSH public key and GPG public key -> SSH key contains much less info.
    nalply : Okay, some things are not possible with SSH keys but I believe that encryption **is possible** since ssh encrypts traffic. Perhaps I should have asked: How can I encrypt a file with an SSH key?
    From Kristaps

How to install GNU/Linux on ADSL router to setup internet watchdog?

What model of ADSL modem/router by major market brand can be used to install some distro of Linux to setup a watchdog to initialize connection by demand in case for example of main internet connection fail? Probably using C#/mono.

  • How about something like a Draytek 2820 or 2930 that supports 2 WAN connections with failover or can failover automatically to a 3G connection?

    If you do want a DIY solution, have a look at this wiki page over at dd-wrt

    abatishchev : Thanks! What is the different between dd-WRT and OpenWRT?
    abatishchev : btw, my main channel is high-speed ethernet and a reserve one - low-speed adsl
    From Linker3000

Postfix on linux not sending mail

For some reason my server has stopped sending mail, and I am not sure why. I am running Debian 5.0 with postfix. I remember setting it up using apt-get, and it worked fine.

Is there a config file that I need to update? Can I send a test email from the shell?

  • Sending a test email from the shell can be accomplished with:

    echo "test-body" | mailx -s "test-subject" username@example.com

    You might need to apt-get mailx or so.

    I'm not familiar with postfix, but maybe there's a log file in /var/log you can look at, or check /var/log/daemon.log.

  • You should check your logfiles

    /var/log/mail.log
    /var/log/mail.err
    /var/log/daemon.log
    

    It would be good to know if your mails are queued:

    mailq
    

    If there are mails in your queue try:

    sendmail -q
    

    Check your postfix service status:

    /etc/init.d/postfix status
    

    Please check your postfix configuration:

    postfix check
    

    Edit:

    Please check your dns setup:

    nslookup www.google.de
    

    Please check if you are able to ping any of the destination domains:

    ping www.google.de
    
    Zed Said : Thanks, I see TONS of emails in the queue. I am using google apps, and see these errors in the queue: delivery temporarily suspended: connect to ASPMX3.GOOGLEMAIL.com[72.14.213.27]:25: No route to host (delivery temporarily suspended: connect to ASPMX4.GOOGLEMAIL.com[209.85.229.27]:25: Connection timed out)
    Andreas Rehm : Please check if your dns setup works - I've edited my post.

How are subdomain resolved?

Hi, quick question for you, when I enter adress like test.mysite.net, first I connect to my ISP DNS, than if not found there to .NET DNS, than to mysite DNS, what after that?

I mean, I know that test.mysite.net could be at different IP adress, but what if I want to run virtual server there? I get the same IP as mysite.net has, and how does server know wheather I want to reach for test.mysite or mysite directly, if they have same IP adress ?

  • This isn't a tricky question.
    It's basic DNS operations to evaluate in the order of .net -> mysite.net -> test.mysite.net, passing the request from one domain DNS server to another.

    See How Lookups Are Handled for a graphical explanation.

    grawity : It's actually `.` -> `net.` -> `mysite.net.` -> `test.mysite.net.`
    harrymc : @grawity: I believe this is optimized, to avoid the entire world soliciting one poor DNS master server.
    dsolimano : @harrymc, you can see the DNS root servers here - http://www.root-servers.org/. Looks like we're up to around 200 physical servers backing up the 13 root server names. But yes, I believe the load on the roots tends to be intense. DNS software will often cache responses so it will know `net.`, but when the cache expires it will go back to `.` to refresh.
    From harrymc

tomcat query timeout

Hi , i have a query oracle so large , and i have to represent the result in a table based in a web application. My problem is that when i want to view the data the web page give me an error, and i think that this error depends on a tomcat query timeout. I would like if is possible modify this timeout and how is possible.

Thanks a lot

ESX Compact Flash

Hello,

I am planning on putting ESX on a compact flash media and making it bootable these will be running on high-performace servers. My question is:

Is CF a good idea and if so what CF read/write speed should I be looking for ESX specifically?

Currently looking at this for the reader:

http://www.lycom.com.tw/ST138.htm

Thanks in advance for your help.

  • You're probably better off with ESXi, as that's much closer to how it's intended to be run.

    Massimo : Not if you want a service console. Which can be very, very useful. But, of course, ESXi is also free...
    ErikA : IMO, anyone banking too much into ESX now is asking for trouble. ESX is going away, so we're all going to need to figure out how to live with ESXi.
    gWaldo : The Service Console is indeed handy, but it's far less powerful than the VI/vSphere Client. Even if you don't spring for vCenter (where you can manage everything under one console), the Client is far more powerful than the Service Console. The only case where I've needed the Service Console was to ssh in to check /var/log.
    Massimo : I disagree: there are things you can do in the SC that you *can't* do in the Client. Try manually editing a .vmx file.
    gWaldo : I'll give you that, Massimo. Slipped my mind; that was a core part of our build process because of the imaging process we used...
    From gWaldo
  • The CF will only be used to boot ESX, so it won't affect VM performance at all. It is indeed a documented and supported scenario to install and run ESX(i) this way.

    James Moore : So ESX is loaded entirely into memory then?
    Scott Warren : I agree with the commenter below you really want to install ESXi because ESX is going away.
    Massimo : ESX isn't going away anytime soon...
    Helvick : ESX 4.1 is the last major version of ESX that VMware will release. All future releases 4.whatever, 5 etc will be ESXi only, or as VMware now call it the vSphere Hypervisor. http://www.vmware.com/support/vsphere4/doc/vsp_esx41_vc41_rel_notes.html
    From Massimo

ASP uploading/transferring images

I have an ASP web service, that allows to various users to put some data in a database and to upload some images. Since the users have different web sites, the web service uploads the image in a first directory in its own space, then calls an ASP web page located in the user's domain passing it the path to the image (correctly stored) as follows:

MResponseBackAsp(Session("Dominio") & "trasferisci.asp?nomefile=" & Session.SessionID & "-" & name)

So, here it comes the trouble, I receive the following message:

Microsoft VBScript runtime error '800a0005' 
Invalid procedure call or argument 
/trasferisci.asp, line 28 Si รจ verificato un errore nel salvataggio dell'immagine

The code relative to that line is commented:

<%  
nomeFile = Request("nomefile")

Dim lStato
Dim objHTTP
Dim strDataIn
'Randomize()

Set objHTTP = CreateObject("Microsoft.XMLHTTP") 
objHTTP.Open "GET", "http://URL/" & nomeFile, False 
objHTTP.Send 
lStato= objHTTP.Status
strDataIn= objHTTP.ResponseBody 'Binario 
Set objHTTP = Nothing 

If (lStato<>200) Or (Err.Number<>0) Then 
  problema = "Errore " & lStato & " o " & Err.Description & "."
End If

newNomeFile = right(nomeFile,len(nomeFile)-instr(nomeFile,"-"))
fileDaSalvare = Server.mapPath(Application("news_immagini") & newNomeFile)

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(fileDaSalvare) Then objFSO.DeleteFile(fileDaSalvare)
Set objFl = objFSO.CreateTextFile(fileDaSalvare, true)
objFl.Write BinaryToString(strDataIn)
objFl.Close()
Set objFl = Nothing
Set objFSO = Nothing

Function BinaryToString(Binary) 
  dim c1, c2, c3, p1, p2, p3 
  Dim L 
  c1 = 1 :  c2 = 1 : c3 = 1 
  L = LenB(Binary) 

  Do While c1<=L 
    p3 = p3 & Chr(AscB(MidB(Binary,c1,1))) 
    c1 = c1 + 1 : c3 = c3 + 1 
    if c3>300 then 
      p2 = p2 & p3 
      p3 = "" 
      c3 = 1 
      c2 = c2 + 1 
      if c2>200 then 
        p1 = p1 & p2 
        p2 = "" 
        c2 = 1 
      End If 
    End If 
  Loop 
  BinaryToString = p1 & p2 & p3 
End Function

Response.write "salvato"
%>

But the best parts come now: 1) If we call trasferisci.asp manually it works; 2) If we refresh the global.asa then it works again for a while

I read somewhere that there could be some problems whit image upload, where is the problem? Suggestions?

Thank you all folks.

PS (edit): I've posted this question here because we think that the problems are into the System, not into the code. I apologyze if it is not.

  • The error message

    Microsoft VBScript runtime error '800a0005'
    Invalid procedure call or argument

    while uploading files is probably related to the server. It may not support some of the newer functions of VBScript.

    Maybe it has an older or outdated version of the Microsoft Data Access Components (MDAC) and/or VBScript.


    By the way, shouldn't you use the

     Response.BinaryWrite()
    

    method when writing binary data?

    Also, I would issue Response.Clear() and set the right HTTP response header (according to the files MIME type): Response.ContentType = "...".

    IssamTP : Thank you for your answer, we've analyzed your suggestions, but unfortunately we couldn't find the solutions. Anyway, just to be sure, we've posted the whole code of the original file "trasferisci.asp", hoping that this will help to fix.
    IssamTP : The DLL version is 8.100.1051.0
    splattne : okay, I see. I just don't understand why you're creating text files if you could save them as binary files. Is there a special reason? I guess the problem could be some strange strings being created from your binary content (image). Also, it could be a problem if browsers/sites use different text encodings (Windows-1252, UTF8, ...)
    IssamTP : Yes, technically it would be better using ADODB.Stream, but the main web programmer says that it causes troubles with anti-virus.
    From splattne